Skip to content

Commit

Permalink
fix: add const to constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
snaoyam committed Aug 3, 2023
1 parent e7aa9c6 commit 6dbe0ce
Show file tree
Hide file tree
Showing 45 changed files with 280 additions and 302 deletions.
27 changes: 14 additions & 13 deletions lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class _OTLHomeState extends State<OTLHome> with SingleTickerProviderStateMixin {
if ((await SharedPreferences.getInstance()).getBool('popup') ?? true) {
await showDialog(
context: context,
builder: (context) => PopUp(),
builder: (context) => const PopUp(),
);
}
},
Expand All @@ -75,7 +75,7 @@ class _OTLHomeState extends State<OTLHome> with SingleTickerProviderStateMixin {

PreferredSizeWidget _buildHomeAppBar() {
return PreferredSize(
preferredSize: Size.fromHeight(5),
preferredSize: const Size.fromHeight(5),
child: AppBar(
flexibleSpace:
SafeArea(child: Container(color: OTLColor.pinksMain, height: 5.0)),
Expand All @@ -89,7 +89,7 @@ class _OTLHomeState extends State<OTLHome> with SingleTickerProviderStateMixin {

PreferredSizeWidget _buildTimeTableAppBar() {
return PreferredSize(
preferredSize: Size.fromHeight(kToolbarHeight + 5),
preferredSize: const Size.fromHeight(kToolbarHeight + 5),
child: SafeArea(
child: Container(
color: OTLColor.pinksLight,
Expand Down Expand Up @@ -138,14 +138,15 @@ class _OTLHomeState extends State<OTLHome> with SingleTickerProviderStateMixin {
tapEffectColorRatio: 0.04,
onTap: () => Navigator.push(context, buildCourseSearchPageRoute()),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
padding:
const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
child: Row(
children: [
SvgPicture.asset('assets/icons/search.svg',
height: 24.0,
width: 24.0,
colorFilter:
ColorFilter.mode(OTLColor.pinksMain, BlendMode.srcIn)),
colorFilter: const ColorFilter.mode(
OTLColor.pinksMain, BlendMode.srcIn)),
const SizedBox(width: 12.0),
Expanded(
child: context.watch<CourseSearchModel>().courseSearchquery,
Expand All @@ -169,7 +170,7 @@ class _OTLHomeState extends State<OTLHome> with SingleTickerProviderStateMixin {

PreferredSizeWidget _buildReviewAppBar() {
return PreferredSize(
preferredSize: Size.fromHeight(kToolbarHeight + 5),
preferredSize: const Size.fromHeight(kToolbarHeight + 5),
child: SafeArea(
child: Container(
color: OTLColor.pinksLight,
Expand Down Expand Up @@ -224,7 +225,7 @@ class _OTLHomeState extends State<OTLHome> with SingleTickerProviderStateMixin {
final layerTop = constraints.biggest.height;
final layerAnimation = RelativeRectTween(
begin: RelativeRect.fromLTRB(0, layerTop, 0, -layerTop),
end: RelativeRect.fromLTRB(0, 0, 0, 0),
end: const RelativeRect.fromLTRB(0, 0, 0, 0),
).animate(CurvedAnimation(
parent: _controller,
curve: Curves.easeInOut,
Expand All @@ -244,7 +245,7 @@ class _OTLHomeState extends State<OTLHome> with SingleTickerProviderStateMixin {
});
}),
TimetablePage(),
DictionaryPage(),
const DictionaryPage(),
ReviewPage(),
],
),
Expand Down Expand Up @@ -273,19 +274,19 @@ class _OTLHomeState extends State<OTLHome> with SingleTickerProviderStateMixin {
},
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home_outlined),
icon: const Icon(Icons.home_outlined),
label: tr("title.home"),
),
BottomNavigationBarItem(
icon: Icon(Icons.table_chart_outlined),
icon: const Icon(Icons.table_chart_outlined),
label: tr("title.timetable"),
),
BottomNavigationBarItem(
icon: Icon(Icons.library_books_outlined),
icon: const Icon(Icons.library_books_outlined),
label: tr("title.dictionary"),
),
BottomNavigationBarItem(
icon: Icon(Icons.rate_review_outlined),
icon: const Icon(Icons.rate_review_outlined),
label: tr("title.review"),
),
],
Expand Down
8 changes: 4 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ void main() {

runApp(
EasyLocalization(
supportedLocales: [Locale('en'), Locale('ko')],
supportedLocales: [const Locale('en'), const Locale('ko')],
path: 'assets/translations',
fallbackLocale: Locale('en'),
fallbackLocale: const Locale('en'),
child: MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => AuthModel()),
Expand Down Expand Up @@ -100,7 +100,7 @@ class OTLFirebaseApp extends StatelessWidget {
} on Error {}

SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.transparent));
const SystemUiOverlayStyle(statusBarColor: Colors.transparent));

return MaterialApp(
builder: (context, child) {
Expand All @@ -118,7 +118,7 @@ class OTLFirebaseApp extends StatelessWidget {
: LoginPage(),
routes: {
LikedReviewPage.route: (_) => LikedReviewPage(),
MyReviewPage.route: (_) => MyReviewPage(),
MyReviewPage.route: (_) => const MyReviewPage(),
LectureDetailPage.route: (_) => LectureDetailPage(),
CourseDetailPage.route: (_) => CourseDetailPage(),
},
Expand Down
19 changes: 12 additions & 7 deletions lib/pages/course_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class CourseDetailPage extends StatelessWidget {
Widget build(BuildContext context) {
final CourseDetailModel courseDetailModel =
context.watch<CourseDetailModel>();
final isEn = EasyLocalization.of(context)?.currentLocale == Locale('en');
final isEn =
EasyLocalization.of(context)?.currentLocale == const Locale('en');

return Scaffold(
appBar: buildAppBar(
Expand All @@ -46,8 +47,8 @@ class CourseDetailPage extends StatelessWidget {
),
child: context.select<CourseDetailModel, bool>((model) => model.hasData)
? _buildBody(context)
: Center(
child: const CircularProgressIndicator(),
: const Center(
child: CircularProgressIndicator(),
),
),
);
Expand Down Expand Up @@ -124,7 +125,8 @@ class CourseDetailPage extends StatelessWidget {

ChoiceChip _buildChoiceChip(
BuildContext context, String selectedFilter, Professor? professor) {
final isEn = EasyLocalization.of(context)?.currentLocale == Locale('en');
final isEn =
EasyLocalization.of(context)?.currentLocale == const Locale('en');

return ChoiceChip(
selectedColor: OTLColor.pinksSub,
Expand Down Expand Up @@ -206,7 +208,8 @@ class CourseDetailPage extends StatelessWidget {
}

Column _buildAttribute(BuildContext context, Course course) {
final isEn = EasyLocalization.of(context)?.currentLocale == Locale('en');
final isEn =
EasyLocalization.of(context)?.currentLocale == const Locale('en');

return Column(
children: <Widget>[
Expand Down Expand Up @@ -252,7 +255,8 @@ class CourseDetailPage extends StatelessWidget {
final _scrollController = ScrollController();
final years = context.select<InfoModel, Set<int>>((model) => model.years);
final courseDetailModel = context.watch<CourseDetailModel>();
final isEn = EasyLocalization.of(context)?.currentLocale == Locale('en');
final isEn =
EasyLocalization.of(context)?.currentLocale == const Locale('en');

return Scrollbar(
controller: _scrollController,
Expand Down Expand Up @@ -299,7 +303,8 @@ class CourseDetailPage extends StatelessWidget {

Widget _buildHistoryRow(BuildContext context, List<Lecture> lectures,
Set<int> years, int semester, String selectedFilter) {
final isEn = EasyLocalization.of(context)?.currentLocale == Locale('en');
final isEn =
EasyLocalization.of(context)?.currentLocale == const Locale('en');

return IntrinsicHeight(
child: Row(
Expand Down
7 changes: 4 additions & 3 deletions lib/pages/course_search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class _CourseSearchPageState extends State<CourseSearchPage> {
IconTextButton(
onTap: () => Navigator.pop(context),
icon: Icons.navigate_before,
padding: EdgeInsets.fromLTRB(0, 16, 16, 16),
padding: const EdgeInsets.fromLTRB(0, 16, 16, 16),
),
Expanded(
child: SearchTextfield(
Expand Down Expand Up @@ -112,7 +112,8 @@ class _CourseSearchPageState extends State<CourseSearchPage> {
style: bodyBold.copyWith(color: OTLColor.pinksMain),
),
style: ButtonStyle(
backgroundColor: MaterialStatePropertyAll(OTLColor.grayF),
backgroundColor:
const MaterialStatePropertyAll(OTLColor.grayF),
shape: MaterialStatePropertyAll(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
Expand All @@ -121,7 +122,7 @@ class _CourseSearchPageState extends State<CourseSearchPage> {
),
),
),
SizedBox(
const SizedBox(
width: 12,
),
Expanded(
Expand Down
7 changes: 4 additions & 3 deletions lib/pages/dictionary_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class _DictionaryPageState extends State<DictionaryPage> {
controller: _scrollController,
child: ListView.separated(
controller: _scrollController,
padding: EdgeInsets.all(12.0),
padding: const EdgeInsets.all(12.0),
itemCount: searchModel.courses?.length ?? 0,
itemBuilder: (context, index) => CourseBlock(
course: searchModel.courses![index],
Expand All @@ -60,7 +60,8 @@ class _DictionaryPageState extends State<DictionaryPage> {
Navigator.push(context, buildCourseDetailPageRoute());
},
),
separatorBuilder: (context, index) => SizedBox(height: 8.0),
separatorBuilder: (context, index) =>
const SizedBox(height: 8.0),
),
);
}
Expand All @@ -74,7 +75,7 @@ Widget _buildCopyRight() {
return Text.rich(
TextSpan(
style: labelRegular.copyWith(color: OTLColor.grayA),
children: [
children: const [
TextSpan(text: 'otlplus@sparcs.org'),
TextSpan(text: '\n'),
TextSpan(text: '© 2023 SPARCS OTL Team'),
Expand Down
18 changes: 10 additions & 8 deletions lib/pages/lecture_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class LectureDetailPage extends StatelessWidget {
Widget build(BuildContext context) {
final LectureDetailModel lectureDetailModel =
context.watch<LectureDetailModel>();
final isEn = EasyLocalization.of(context)?.currentLocale == Locale('en');
final isEn =
EasyLocalization.of(context)?.currentLocale == const Locale('en');

return Scaffold(
appBar: buildAppBar(
Expand All @@ -57,8 +58,8 @@ class LectureDetailPage extends StatelessWidget {
child:
context.select<LectureDetailModel, bool>((model) => model.hasData)
? _buildBody(context)
: Center(
child: const CircularProgressIndicator(),
: const Center(
child: CircularProgressIndicator(),
),
),
);
Expand Down Expand Up @@ -115,7 +116,7 @@ class LectureDetailPage extends StatelessWidget {
"시간이 겹치는 수업이 있습니다. 추가하시면 해당 수업은 삭제됩니다.\n시간표에 추가하시겠습니까?"),
actions: [
IconTextButton(
padding: EdgeInsets.all(12),
padding: const EdgeInsets.all(12),
text: 'common.cancel'.tr(),
color: OTLColor.pinksMain,
onTap: () {
Expand All @@ -124,7 +125,7 @@ class LectureDetailPage extends StatelessWidget {
},
),
IconTextButton(
padding: EdgeInsets.all(12),
padding: const EdgeInsets.all(12),
text: 'common.add'.tr(),
color: OTLColor.pinksMain,
onTap: () {
Expand Down Expand Up @@ -165,7 +166,7 @@ class LectureDetailPage extends StatelessWidget {
IconTextButton(
onTap: () => FlutterWebBrowser.openWebPage(
url: _getSyllabusUrl(lecture),
customTabsOptions: CustomTabsOptions(
customTabsOptions: const CustomTabsOptions(
colorScheme: CustomTabsColorScheme.light,
defaultColorSchemeParams: CustomTabsColorSchemeParams(
toolbarColor: OTLColor.pinksLight),
Expand All @@ -174,7 +175,7 @@ class LectureDetailPage extends StatelessWidget {
showTitle: true,
urlBarHidingEnabled: true,
),
safariVCOptions: SafariViewControllerOptions(
safariVCOptions: const SafariViewControllerOptions(
barCollapsingEnabled: true,
dismissButtonStyle: SafariViewControllerDismissButtonStyle.close,
modalPresentationCapturesStatusBarAppearance: true,
Expand Down Expand Up @@ -332,7 +333,8 @@ class LectureDetailPage extends StatelessWidget {
}

Widget _buildAttributes(BuildContext context, Lecture lecture) {
final isEn = EasyLocalization.of(context)?.currentLocale == Locale('en');
final isEn =
EasyLocalization.of(context)?.currentLocale == const Locale('en');

return Column(
children: [
Expand Down
7 changes: 4 additions & 3 deletions lib/pages/lecture_search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class _LectureSearchPageState extends State<LectureSearchPage> {
IconTextButton(
onTap: () => Navigator.pop(context),
icon: Icons.navigate_before,
padding: EdgeInsets.fromLTRB(0, 16, 16, 16),
padding: const EdgeInsets.fromLTRB(0, 16, 16, 16),
),
Expanded(
child: SearchTextfield(
Expand Down Expand Up @@ -112,7 +112,8 @@ class _LectureSearchPageState extends State<LectureSearchPage> {
style: bodyBold.copyWith(color: OTLColor.pinksMain),
),
style: ButtonStyle(
backgroundColor: MaterialStatePropertyAll(OTLColor.grayF),
backgroundColor:
const MaterialStatePropertyAll(OTLColor.grayF),
shape: MaterialStatePropertyAll(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
Expand All @@ -121,7 +122,7 @@ class _LectureSearchPageState extends State<LectureSearchPage> {
),
),
),
SizedBox(
const SizedBox(
width: 12,
),
Expanded(
Expand Down
8 changes: 4 additions & 4 deletions lib/pages/liked_review_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ class LikedReviewPage extends StatelessWidget {
),
SliverList(
delegate: SliverChildListDelegate([
Padding(
padding: const EdgeInsets.only(
top: 4.0, bottom: 12.0),
child: const Center(
const Padding(
padding:
EdgeInsets.only(top: 4.0, bottom: 12.0),
child: Center(
child: SizedBox(
width: 24,
height: 24,
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class _LoginPageState extends State<LoginPage> {
body: Material(
child: Stack(
children: <Widget>[
Center(
child: const CircularProgressIndicator(),
const Center(
child: CircularProgressIndicator(),
),
_buildBody(context),
],
Expand Down
Loading

0 comments on commit 6dbe0ce

Please sign in to comment.