diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 5ba3e47bf..1f3ebf523 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -101,7 +101,7 @@ jobs: with: commit_message: "Bump app version [no ci]" - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: java-version: ${{env.JAVA_VERSION}} distribution: "zulu" diff --git a/.github/workflows/format_lint_test.yaml b/.github/workflows/format_lint_test.yaml index 824fad69d..cad1a0329 100644 --- a/.github/workflows/format_lint_test.yaml +++ b/.github/workflows/format_lint_test.yaml @@ -37,7 +37,7 @@ jobs: - name: Clone repository uses: actions/checkout@v4 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: java-version: ${{ env.JAVA_VERSION }} distribution: zulu @@ -49,7 +49,11 @@ jobs: flutter-version-file: uni/pubspec.yaml cache: true - - run: flutter analyze . + - run: flutter pub get + + - run: | + flutter analyze . + dart run custom_lint test: name: Test @@ -60,7 +64,7 @@ jobs: working-directory: ./uni steps: - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: java-version: ${{ env.JAVA_VERSION }} distribution: zulu diff --git a/uni/analysis_options.yaml b/uni/analysis_options.yaml index 44ceb645f..f943b88cd 100644 --- a/uni/analysis_options.yaml +++ b/uni/analysis_options.yaml @@ -6,3 +6,5 @@ analyzer: - "**.g.dart" - "**.mocks.dart" - "**generated/**" + plugins: + - custom_lint diff --git a/uni/lib/controller/background_workers/background_callback.dart b/uni/lib/controller/background_workers/background_callback.dart index 3f1664db7..1283b05fc 100644 --- a/uni/lib/controller/background_workers/background_callback.dart +++ b/uni/lib/controller/background_workers/background_callback.dart @@ -32,14 +32,14 @@ Future workerStartCallback() async { }); return true; } - //try to keep the usage of this function BELOW +-30 seconds - //to not be punished by the scheduler in future runs. + // try to keep the usage of this function BELOW +-30 seconds + // to not be punished by the scheduler in future runs. await taskMap[taskName]!.item1(); - } catch (err, stackTrace) { + } catch (err, st) { Logger().e( 'Error while running $taskName job:', error: err, - stackTrace: stackTrace, + stackTrace: st, ); return false; } diff --git a/uni/lib/controller/background_workers/notifications.dart b/uni/lib/controller/background_workers/notifications.dart index 7f5c7d34c..7cc56a511 100644 --- a/uni/lib/controller/background_workers/notifications.dart +++ b/uni/lib/controller/background_workers/notifications.dart @@ -125,7 +125,7 @@ class NotificationManager { const initializationSettingsAndroid = AndroidInitializationSettings('ic_notification'); - //request for notifications immediatly on iOS + // request for notifications immediatly on iOS const darwinInitializationSettings = DarwinInitializationSettings( requestCriticalPermission: true, ); @@ -157,7 +157,7 @@ class NotificationManager { if (Platform.isAndroid) { await Workmanager().cancelByUniqueName( 'pt.up.fe.ni.uni.notificationworker', - ); //stop task if it's already running + ); // stop task if it's already running await Workmanager().registerPeriodicTask( 'pt.up.fe.ni.uni.notificationworker', 'pt.up.fe.ni.uni.notificationworker', diff --git a/uni/lib/controller/cleanup.dart b/uni/lib/controller/cleanup.dart index c30d4a2b5..79fc319c1 100644 --- a/uni/lib/controller/cleanup.dart +++ b/uni/lib/controller/cleanup.dart @@ -61,7 +61,7 @@ Future cleanDirectory(Directory directory, DateTime threshold) async { try { final fileDate = file.lastModifiedSync(); return fileDate.isBefore(threshold) && path.extension(file.path) != '.db'; - } catch (e) { + } catch (err) { return false; } }); diff --git a/uni/lib/controller/fetchers/departures_fetcher.dart b/uni/lib/controller/fetchers/departures_fetcher.dart index 23868b0ab..1ef9dbafd 100644 --- a/uni/lib/controller/fetchers/departures_fetcher.dart +++ b/uni/lib/controller/fetchers/departures_fetcher.dart @@ -45,17 +45,17 @@ class DeparturesFetcher { callParam.lastIndexOf("'"), ); return csrfToken; - } catch (e, stackTrace) { + } catch (err, st) { unawaited( Sentry.captureEvent( SentryEvent( - throwable: e, + throwable: err, request: SentryRequest( url: url, data: response.body, ), ), - stackTrace: stackTrace, + stackTrace: st, ), ); rethrow; diff --git a/uni/lib/controller/local_storage/database/app_calendar_database.dart b/uni/lib/controller/local_storage/database/app_calendar_database.dart index 6e05891b6..c4ff2b1ff 100644 --- a/uni/lib/controller/local_storage/database/app_calendar_database.dart +++ b/uni/lib/controller/local_storage/database/app_calendar_database.dart @@ -21,7 +21,7 @@ class CalendarDatabase extends AppDatabase { }); } - //Returns a list with all calendar events stored in the database + // Returns a list with all calendar events stored in the database Future> calendar() async { final db = await getDatabase(); diff --git a/uni/lib/controller/local_storage/database/app_restaurant_database.dart b/uni/lib/controller/local_storage/database/app_restaurant_database.dart index 5e15a20f2..7e1ceb6c3 100644 --- a/uni/lib/controller/local_storage/database/app_restaurant_database.dart +++ b/uni/lib/controller/local_storage/database/app_restaurant_database.dart @@ -93,11 +93,11 @@ class RestaurantDatabase extends AppDatabase { whereArgs.add(toString(day)); } - //Get restaurant meals + // Get restaurant meals final List> mealsMaps = await txn.query('meals', where: whereQuery, whereArgs: whereArgs); - //Retrieve data from query + // Retrieve data from query final meals = mealsMaps.map((map) { final day = parseDayOfWeek(map['day'] as String); final type = map['type'] as String; diff --git a/uni/lib/controller/local_storage/notification_timeout_storage.dart b/uni/lib/controller/local_storage/notification_timeout_storage.dart index b74800271..cf924b432 100644 --- a/uni/lib/controller/local_storage/notification_timeout_storage.dart +++ b/uni/lib/controller/local_storage/notification_timeout_storage.dart @@ -30,7 +30,7 @@ class NotificationTimeoutStorage { if (!_fileContent.containsKey(uniqueID)) { return DateTime.fromMicrosecondsSinceEpoch( 0, - ); //get 1970 to always trigger notification + ); // get 1970 to always trigger notification } return DateTime.parse(_fileContent[uniqueID] as String); } @@ -51,7 +51,7 @@ class NotificationTimeoutStorage { final applicationDirectory = (await getApplicationDocumentsDirectory()).path; if (!File('$applicationDirectory/notificationTimeout.json').existsSync()) { - //empty json + // empty json await File('$applicationDirectory/notificationTimeout.json') .writeAsString('{}'); } diff --git a/uni/lib/controller/local_storage/preferences_controller.dart b/uni/lib/controller/local_storage/preferences_controller.dart index e3bacac05..71b103838 100644 --- a/uni/lib/controller/local_storage/preferences_controller.dart +++ b/uni/lib/controller/local_storage/preferences_controller.dart @@ -283,7 +283,7 @@ class PreferencesController { final encrypter = _createEncrypter(); try { return encrypter.decrypt64(base64Text, iv: iv); - } catch (e) { + } catch (_) { return null; } } diff --git a/uni/lib/controller/parsers/parser_library_occupation.dart b/uni/lib/controller/parsers/parser_library_occupation.dart index 7f216537f..e2abae3f1 100644 --- a/uni/lib/controller/parsers/parser_library_occupation.dart +++ b/uni/lib/controller/parsers/parser_library_occupation.dart @@ -21,12 +21,12 @@ Future parseLibraryOccupationFromSheets( int max; try { floor = (jsonDecoded['table']['rows'][i]['c'][0]['v'] as double).toInt(); - } catch (e) { + } catch (err) { floor = 0; } try { max = (jsonDecoded['table']['rows'][i]['c'][1]['v'] as double).toInt(); - } catch (e) { + } catch (err) { max = 0; } occupation.addFloor(FloorOccupation(i + 1, floor, max)); diff --git a/uni/lib/controller/parsers/parser_restaurants.dart b/uni/lib/controller/parsers/parser_restaurants.dart index 69cd921c9..7ca640558 100644 --- a/uni/lib/controller/parsers/parser_restaurants.dart +++ b/uni/lib/controller/parsers/parser_restaurants.dart @@ -14,7 +14,7 @@ import 'package:uni/model/utils/day_of_week.dart'; List getRestaurantsFromHtml(Response response) { final document = parse(response.body); - //Get restaurant reference number and name + // Get restaurant reference number and name final restaurantsHtml = document.querySelectorAll('#conteudoinner ul li > a'); final restaurantsTuple = restaurantsHtml.map((restaurantHtml) { @@ -23,7 +23,7 @@ List getRestaurantsFromHtml(Response response) { return Tuple2(ref ?? '', name); }).toList(); - //Get restaurant meals and create the Restaurant class + // Get restaurant meals and create the Restaurant class final restaurants = restaurantsTuple.map((restaurantTuple) { final meals = []; @@ -35,14 +35,14 @@ List getRestaurantsFromHtml(Response response) { while (next != null && next.attributes['name'] == null) { next = next.nextElementSibling; if (next!.classes.contains('dados')) { - //It's the menu table + // It's the menu table final rows = next.querySelectorAll('tr'); - //Check if is empty + // Check if is empty if (rows.length <= 1) { break; } - //Read rows, first row is ignored because it's the header + // Read rows, first row is ignored because it's the header rows.getRange(1, rows.length).forEach((row) { DayOfWeek? dayOfWeek; String? type; @@ -55,7 +55,7 @@ List getRestaurantsFromHtml(Response response) { if (header == 'Data') { final d = parseDayOfWeek(value); if (d == null) { - //It's a date + // It's a date date = format.parseUtc(value); } else { dayOfWeek = d; diff --git a/uni/lib/controller/parsers/parser_schedule_html.dart b/uni/lib/controller/parsers/parser_schedule_html.dart index 8d2796b75..f406724da 100644 --- a/uni/lib/controller/parsers/parser_schedule_html.dart +++ b/uni/lib/controller/parsers/parser_schedule_html.dart @@ -82,7 +82,7 @@ Future> getOverlappedClasses( ) .first, ); - } catch (e) { + } catch (_) { final lect = Lecture.fromHtml( subject!, typeClass!, diff --git a/uni/lib/model/entities/calendar_event.dart b/uni/lib/model/entities/calendar_event.dart index 30fc653d3..59336b55d 100644 --- a/uni/lib/model/entities/calendar_event.dart +++ b/uni/lib/model/entities/calendar_event.dart @@ -24,7 +24,7 @@ class CalendarEvent { try { return DateFormat('dd MMMM yyyy', 'pt') .parse('${splitDate[0]} $month ${splitDate.last}'); - } catch (e) { + } catch (_) { return null; } } diff --git a/uni/lib/model/providers/startup/session_provider.dart b/uni/lib/model/providers/startup/session_provider.dart index 8fbb74eb1..d22f8fbbb 100644 --- a/uni/lib/model/providers/startup/session_provider.dart +++ b/uni/lib/model/providers/startup/session_provider.dart @@ -76,7 +76,7 @@ class SessionProvider extends StateProviderNotifier { persistentSession: persistentSession, ignoreCached: true, ); - } catch (e) { + } catch (_) { throw InternetStatusException(locale); } diff --git a/uni/lib/model/providers/state_provider_notifier.dart b/uni/lib/model/providers/state_provider_notifier.dart index 55c08367a..2b47392fc 100644 --- a/uni/lib/model/providers/state_provider_notifier.dart +++ b/uni/lib/model/providers/state_provider_notifier.dart @@ -81,10 +81,9 @@ abstract class StateProviderNotifier extends ChangeNotifier { try { setState(await loadFromStorage(StateProviders.fromContext(context))); - } catch (e, stackTrace) { - await Sentry.captureException(e, stackTrace: stackTrace); - Logger() - .e('Failed to load $runtimeType info from storage: $e\n$stackTrace'); + } catch (err, st) { + await Sentry.captureException(err, stackTrace: st); + Logger().e('Failed to load $runtimeType info from storage: $err\n$st'); _updateStatus(RequestStatus.failed); } @@ -135,10 +134,9 @@ abstract class StateProviderNotifier extends ChangeNotifier { ); _updateStatus(RequestStatus.successful); - } catch (e, stackTrace) { - await Sentry.captureException(e, stackTrace: stackTrace); - Logger() - .e('Failed to load $runtimeType info from remote: $e\n$stackTrace'); + } catch (err, st) { + await Sentry.captureException(err, stackTrace: st); + Logger().e('Failed to load $runtimeType info from remote: $err\n$st'); _updateStatus(RequestStatus.failed); } } diff --git a/uni/lib/view/academic_path/widgets/course_units_card.dart b/uni/lib/view/academic_path/widgets/course_units_card.dart index 03ed19899..687e8ee08 100644 --- a/uni/lib/view/academic_path/widgets/course_units_card.dart +++ b/uni/lib/view/academic_path/widgets/course_units_card.dart @@ -58,13 +58,9 @@ class CourseUnitsCard extends GenericCard { return Column( children: courseUnits .map( - (courseUnit) => Column( - children: [ - Padding( - padding: const EdgeInsets.all(5), - child: CourseUnitCard(courseUnit), - ), - ], + (courseUnit) => Padding( + padding: const EdgeInsets.all(5), + child: CourseUnitCard(courseUnit), ), ) .toList(), diff --git a/uni/lib/view/bug_report/widgets/form.dart b/uni/lib/view/bug_report/widgets/form.dart index 111938515..14d5403a8 100644 --- a/uni/lib/view/bug_report/widgets/form.dart +++ b/uni/lib/view/bug_report/widgets/form.dart @@ -262,9 +262,9 @@ class BugReportFormState extends State { toastMsg = s.success; } status = true; - } catch (e, stackTrace) { - await Sentry.captureException(e, stackTrace: stackTrace); - Logger().e('Error while posting bug report:$e'); + } catch (err, st) { + await Sentry.captureException(err, stackTrace: st); + Logger().e('Error while posting bug report:$err'); if (context.mounted) { toastMsg = s.sent_error; } diff --git a/uni/lib/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart b/uni/lib/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart index 1c32963da..85705edac 100644 --- a/uni/lib/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart +++ b/uni/lib/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart @@ -63,18 +63,14 @@ class BusStopNextArrivalsPageState color: Theme.of(context).colorScheme.primary, ), ), - Column( - children: [ - ElevatedButton( - onPressed: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const BusStopSelectionPage(), - ), - ), - child: Text(S.of(context).add), + ElevatedButton( + onPressed: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const BusStopSelectionPage(), ), - ], + ), + child: Text(S.of(context).add), ), ], ), @@ -175,22 +171,18 @@ class NextArrivalsState extends State { widget.buses.forEach((stopCode, stopData) { rows.add( - Column( - children: [ - Container( - padding: const EdgeInsets.only( - top: 8, - bottom: 8, - left: 22, - right: 22, - ), - child: BusStopRow( - stopCode: stopCode, - trips: widget.buses[stopCode]?.trips ?? [], - stopCodeShow: false, - ), - ), - ], + Container( + padding: const EdgeInsets.only( + top: 8, + bottom: 8, + left: 22, + right: 22, + ), + child: BusStopRow( + stopCode: stopCode, + trips: widget.buses[stopCode]?.trips ?? [], + stopCodeShow: false, + ), ), ); }); diff --git a/uni/lib/view/bus_stop_selection/widgets/bus_stop_search.dart b/uni/lib/view/bus_stop_selection/widgets/bus_stop_search.dart index 72aeaefa4..8c1b03b79 100644 --- a/uni/lib/view/bus_stop_selection/widgets/bus_stop_search.dart +++ b/uni/lib/view/bus_stop_selection/widgets/bus_stop_search.dart @@ -40,7 +40,7 @@ class BusStopSearch extends SearchDelegate { @override Widget buildLeading(BuildContext context) { - //Back arrow to go back to menu + // Back arrow to go back to menu return IconButton( icon: const Icon(Icons.arrow_back), diff --git a/uni/lib/view/common_widgets/last_update_timestamp.dart b/uni/lib/view/common_widgets/last_update_timestamp.dart index 3912aec73..403fb1e19 100644 --- a/uni/lib/view/common_widgets/last_update_timestamp.dart +++ b/uni/lib/view/common_widgets/last_update_timestamp.dart @@ -39,6 +39,7 @@ class _LastUpdateTimeStampState> return Consumer( builder: (context, provider, _) => Container( padding: const EdgeInsets.only(top: 8, bottom: 10), + alignment: Alignment.centerLeft, child: provider.lastUpdateTime != null ? _getContent(context, provider.lastUpdateTime!) : null, @@ -53,13 +54,9 @@ class _LastUpdateTimeStampState> elapsedTimeMinutes = 0; } - return Row( - children: [ - Text( - S.of(context).last_timestamp(elapsedTimeMinutes), - style: Theme.of(context).textTheme.titleSmall, - ), - ], + return Text( + S.of(context).last_timestamp(elapsedTimeMinutes), + style: Theme.of(context).textTheme.titleSmall, ); } } diff --git a/uni/lib/view/common_widgets/pages_layouts/general/general.dart b/uni/lib/view/common_widgets/pages_layouts/general/general.dart index 5ea94a8ff..64f54de94 100644 --- a/uni/lib/view/common_widgets/pages_layouts/general/general.dart +++ b/uni/lib/view/common_widgets/pages_layouts/general/general.dart @@ -37,14 +37,14 @@ abstract class GeneralPageViewState extends State { try { await onLoad(context); - } catch (e, stackTrace) { - if (e is SocketException) { + } catch (err, st) { + if (err is SocketException) { setState(() { _connected = false; }); } else { - Logger().e('Failed to load page info: $e\n$stackTrace'); - await Sentry.captureException(e, stackTrace: stackTrace); + Logger().e('Failed to load page info: $err\n$st'); + await Sentry.captureException(err, stackTrace: st); } } @@ -79,16 +79,7 @@ abstract class GeneralPageViewState extends State { return getScaffold( context, _loading - ? const Flex( - direction: Axis.vertical, - children: [ - Expanded( - child: Center( - child: CircularProgressIndicator(), - ), - ), - ], - ) + ? const Center(child: CircularProgressIndicator()) : getBody(context), ); } diff --git a/uni/lib/view/course_unit_info/widgets/course_unit_sheet.dart b/uni/lib/view/course_unit_info/widgets/course_unit_sheet.dart index e113055f3..7a408ced0 100644 --- a/uni/lib/view/course_unit_info/widgets/course_unit_sheet.dart +++ b/uni/lib/view/course_unit_info/widgets/course_unit_sheet.dart @@ -65,7 +65,7 @@ class CourseUnitSheetView extends StatelessWidget { .toList(), ), ); - } catch (e) { + } catch (_) { return null; } } diff --git a/uni/lib/view/exams/widgets/exam_time.dart b/uni/lib/view/exams/widgets/exam_time.dart index de8705099..dbe4d10f0 100644 --- a/uni/lib/view/exams/widgets/exam_time.dart +++ b/uni/lib/view/exams/widgets/exam_time.dart @@ -6,11 +6,6 @@ class ExamTime extends StatelessWidget { @override Widget build(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Text(begin, style: Theme.of(context).textTheme.bodyMedium), - ], - ); + return Text(begin, style: Theme.of(context).textTheme.bodyMedium); } } diff --git a/uni/lib/view/faculty/widgets/other_links_card.dart b/uni/lib/view/faculty/widgets/other_links_card.dart index d4960e737..99070640c 100644 --- a/uni/lib/view/faculty/widgets/other_links_card.dart +++ b/uni/lib/view/faculty/widgets/other_links_card.dart @@ -10,15 +10,12 @@ class OtherLinksCard extends GenericExpansionCard { @override Widget buildCardContent(BuildContext context) { - return const Column( - children: [ - // LinkButton(title: S.of(context).print, link: 'https://print.up.pt'), - // TODO(Process-ing): Get fixed link - LinkButton( - title: 'Consultas SASUP', - link: 'https://www.up.pt/portal/pt/sasup/saude/marcar-consulta/', - ), - ], + // TODO(Process-ing): Get fixed link + // LinkButton(title: S.of(context).print, link: 'https://print.up.pt'), + + return const LinkButton( + title: 'Consultas SASUP', + link: 'https://www.up.pt/portal/pt/sasup/saude/marcar-consulta/', ); } diff --git a/uni/lib/view/home/widgets/exam_card_shimmer.dart b/uni/lib/view/home/widgets/exam_card_shimmer.dart index 86ca3edc8..837ffe4ca 100644 --- a/uni/lib/view/home/widgets/exam_card_shimmer.dart +++ b/uni/lib/view/home/widgets/exam_card_shimmer.dart @@ -17,26 +17,21 @@ class ExamCardShimmer extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - //timestamp section - Container( - height: 15, - width: 40, - color: Colors.black, - ), - const SizedBox( - height: 2.5, - ), - Container( - height: 15, - width: 40, - color: Colors.black, - ), - ], + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + // timestamp section + Container( + height: 15, + width: 40, + color: Colors.black, + ), + const SizedBox( + height: 2.5, + ), + Container( + height: 15, + width: 40, + color: Colors.black, ), ], ), @@ -44,12 +39,12 @@ class ExamCardShimmer extends StatelessWidget { height: 30, width: 100, color: Colors.black, - ), //UC section + ), // UC section Container( height: 40, width: 40, color: Colors.black, - ), //Calender add section + ), // Calender add section ], ), ), diff --git a/uni/lib/view/home/widgets/main_cards_list.dart b/uni/lib/view/home/widgets/main_cards_list.dart index 9950f1ccb..90084907a 100644 --- a/uni/lib/view/home/widgets/main_cards_list.dart +++ b/uni/lib/view/home/widgets/main_cards_list.dart @@ -108,7 +108,7 @@ class MainCardsListState extends State { ], ); }, - ), //Add FAB functionality here + ), // Add FAB functionality here tooltip: S.of(context).add_widget, child: Icon(Icons.add, color: Theme.of(context).colorScheme.onPrimary), ); diff --git a/uni/lib/view/home/widgets/restaurant_card.dart b/uni/lib/view/home/widgets/restaurant_card.dart index 76a116851..65007f82d 100644 --- a/uni/lib/view/home/widgets/restaurant_card.dart +++ b/uni/lib/view/home/widgets/restaurant_card.dart @@ -102,15 +102,10 @@ class RestaurantCard extends GenericCard { physics: const NeverScrollableScrollPhysics(), itemCount: restaurants.length, itemBuilder: (context, index) { - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - createRowFromRestaurant( - context, - restaurants[index], - DayOfWeek.values[offset], - ), - ], + return createRowFromRestaurant( + context, + restaurants[index], + DayOfWeek.values[offset], ); }, ); diff --git a/uni/lib/view/home/widgets/restaurant_row.dart b/uni/lib/view/home/widgets/restaurant_row.dart index df670e0ae..49735a185 100644 --- a/uni/lib/view/home/widgets/restaurant_row.dart +++ b/uni/lib/view/home/widgets/restaurant_row.dart @@ -23,15 +23,10 @@ class RestaurantRow extends StatelessWidget { return Container( padding: const EdgeInsets.only(left: 12, bottom: 8, right: 12), margin: const EdgeInsets.only(top: 8), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Column( - children: getMenuRows(context), - ), - ), - ], + child: Expanded( + child: Column( + children: getMenuRows(context), + ), ), ); } diff --git a/uni/lib/view/home/widgets/schedule_card_shimmer.dart b/uni/lib/view/home/widgets/schedule_card_shimmer.dart index 32fdbb93d..91728fd9d 100644 --- a/uni/lib/view/home/widgets/schedule_card_shimmer.dart +++ b/uni/lib/view/home/widgets/schedule_card_shimmer.dart @@ -14,26 +14,21 @@ class ScheduleCardShimmer extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - //timestamp section - Container( - height: 15, - width: 40, - color: Colors.black, - ), - const SizedBox( - height: 2.5, - ), - Container( - height: 15, - width: 40, - color: Colors.black, - ), - ], + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + // timestamp section + Container( + height: 15, + width: 40, + color: Colors.black, + ), + const SizedBox( + height: 2.5, + ), + Container( + height: 15, + width: 40, + color: Colors.black, ), ], ), @@ -44,7 +39,7 @@ class ScheduleCardShimmer extends StatelessWidget { height: 25, width: 100, color: Colors.black, - ), //UC section + ), // UC section const SizedBox( height: 10, ), @@ -52,14 +47,14 @@ class ScheduleCardShimmer extends StatelessWidget { height: 15, width: 150, color: Colors.black, - ), //UC section + ), // UC section ], ), Container( height: 15, width: 40, color: Colors.black, - ), //Room section + ), // Room section ], ), ), @@ -76,7 +71,7 @@ class ScheduleCardShimmer extends StatelessWidget { height: 15, width: 80, color: Colors.black, - ), //Day of the week + ), // Day of the week const SizedBox( height: 10, ), diff --git a/uni/lib/view/lazy_consumer.dart b/uni/lib/view/lazy_consumer.dart index fa892c01c..ba0a910fe 100644 --- a/uni/lib/view/lazy_consumer.dart +++ b/uni/lib/view/lazy_consumer.dart @@ -42,7 +42,7 @@ class LazyConsumer, T2> StateProviderNotifier? provider; try { provider = Provider.of(context, listen: false); - } catch (e) { + } catch (_) { // The provider was not found. This should only happen in tests. Logger().e('LazyConsumer: ${T1.runtimeType} not found'); return; @@ -60,14 +60,14 @@ class LazyConsumer, T2> .ensureInitialized(context); }) : Future(() {}); - } catch (exception, stackTrace) { + } catch (err, st) { // In tests, it is ok to not find the startup providers: // all provider data should be mocked by the test itself. if (!Platform.environment.containsKey('FLUTTER_TEST')) { Logger().e( - 'Failed to initialize startup providers: $exception', + 'Failed to initialize startup providers: $err', ); - await Sentry.captureException(exception, stackTrace: stackTrace); + await Sentry.captureException(err, stackTrace: st); } } diff --git a/uni/lib/view/locations/widgets/floorless_marker_popup.dart b/uni/lib/view/locations/widgets/floorless_marker_popup.dart index 60b7b5574..f165c5808 100644 --- a/uni/lib/view/locations/widgets/floorless_marker_popup.dart +++ b/uni/lib/view/locations/widgets/floorless_marker_popup.dart @@ -40,15 +40,10 @@ class FloorlessLocationMarkerPopup extends StatelessWidget { List buildLocations(BuildContext context, List locations) { return locations .map( - (location) => Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - location.description(), - textAlign: TextAlign.left, - style: TextStyle(color: FacultyMap.getFontColor(context)), - ), - ], + (location) => Text( + location.description(), + textAlign: TextAlign.left, + style: TextStyle(color: FacultyMap.getFontColor(context)), ), ) .toList(); @@ -61,15 +56,10 @@ class LocationRow extends StatelessWidget { @override Widget build(BuildContext context) { - return Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - location.description(), - textAlign: TextAlign.left, - style: TextStyle(color: FacultyMap.getFontColor(context)), - ), - ], + return Text( + location.description(), + textAlign: TextAlign.left, + style: TextStyle(color: FacultyMap.getFontColor(context)), ); } } diff --git a/uni/lib/view/locations/widgets/marker_popup.dart b/uni/lib/view/locations/widgets/marker_popup.dart index 1c46a3fd9..04391c939 100644 --- a/uni/lib/view/locations/widgets/marker_popup.dart +++ b/uni/lib/view/locations/widgets/marker_popup.dart @@ -56,23 +56,18 @@ class Floor extends StatelessWidget { Widget build(BuildContext context) { final fontColor = FacultyMap.getFontColor(context); - final floorString = 0 <= floor && floor <= 9 //To maintain layout of popup + final floorString = 0 <= floor && floor <= 9 // To maintain layout of popup ? ' $floor' : '$floor'; return Row( children: [ - Column( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), - child: Text( - '${S.of(context).floor} $floorString', - style: TextStyle(color: fontColor), - ), - ), - ], + Container( + padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), + child: Text( + '${S.of(context).floor} $floorString', + style: TextStyle(color: fontColor), + ), ), Container( padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), @@ -102,16 +97,11 @@ class LocationRow extends StatelessWidget { @override Widget build(BuildContext context) { - return Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - location.description(), - textAlign: TextAlign.left, - overflow: TextOverflow.ellipsis, - style: TextStyle(color: color), - ), - ], + return Text( + location.description(), + textAlign: TextAlign.left, + overflow: TextOverflow.ellipsis, + style: TextStyle(color: color), ); } } diff --git a/uni/lib/view/login/login.dart b/uni/lib/view/login/login.dart index 94067e1a0..ec07b5dc9 100644 --- a/uni/lib/view/login/login.dart +++ b/uni/lib/view/login/login.dart @@ -69,23 +69,23 @@ class LoginPageViewState extends State { _loggingIn = false; }); } - } catch (error, stackTrace) { + } catch (err, st) { setState(() { _loggingIn = false; }); - if (error is ExpiredCredentialsException) { + if (err is ExpiredCredentialsException) { updatePasswordDialog(); - } else if (error is InternetStatusException) { + } else if (err is InternetStatusException) { if (context.mounted) { - unawaited(ToastMessage.warning(context, error.message)); + unawaited(ToastMessage.warning(context, err.message)); } - } else if (error is WrongCredentialsException) { + } else if (err is WrongCredentialsException) { if (context.mounted) { - unawaited(ToastMessage.error(context, error.message)); + unawaited(ToastMessage.error(context, err.message)); } } else { - Logger().e(error, stackTrace: stackTrace); - unawaited(Sentry.captureException(error, stackTrace: stackTrace)); + Logger().e(err, stackTrace: st); + unawaited(Sentry.captureException(err, stackTrace: st)); if (context.mounted) { unawaited(ToastMessage.error(context, S.of(context).failed_login)); } @@ -186,17 +186,12 @@ class LoginPageViewState extends State { minWidth: queryData.size.width / 8, minHeight: queryData.size.height / 6, ), - child: Column( - children: [ - SizedBox( - width: 100, - child: SvgPicture.asset( - 'assets/images/logo_dark.svg', - colorFilter: - const ColorFilter.mode(Colors.white, BlendMode.srcIn), - ), - ), - ], + child: SizedBox( + width: 100, + child: SvgPicture.asset( + 'assets/images/logo_dark.svg', + colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn), + ), ), ); } @@ -242,7 +237,7 @@ class LoginPageViewState extends State { ); } - ///Creates the widget for when the user forgets the password + /// Creates the widget for when the user forgets the password Widget createForgetPasswordLink(BuildContext context) { return InkWell( child: Center( diff --git a/uni/lib/view/profile/widgets/account_info_card.dart b/uni/lib/view/profile/widgets/account_info_card.dart index 3d0274309..b6b4ebda7 100644 --- a/uni/lib/view/profile/widgets/account_info_card.dart +++ b/uni/lib/view/profile/widgets/account_info_card.dart @@ -102,15 +102,11 @@ class AccountInfoCard extends GenericCard { right: 15, left: 15, ), - child: Row( - children: [ - Text( - S.of(context).pendent_references, - style: Theme.of(context).textTheme.titleLarge?.apply( - color: Theme.of(context).colorScheme.secondary, - ), - ), - ], + child: Text( + S.of(context).pendent_references, + style: Theme.of(context).textTheme.titleLarge?.apply( + color: Theme.of(context).colorScheme.secondary, + ), ), ), ReferenceList(references: references), diff --git a/uni/lib/view/restaurant/restaurant_page_view.dart b/uni/lib/view/restaurant/restaurant_page_view.dart index c55b53cb8..2d36b4e20 100644 --- a/uni/lib/view/restaurant/restaurant_page_view.dart +++ b/uni/lib/view/restaurant/restaurant_page_view.dart @@ -137,12 +137,7 @@ class _RestaurantPageViewState extends GeneralPageViewState return Container( margin: const EdgeInsets.only(bottom: 5), key: Key('restaurant-page-day-column-$day'), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Center(child: Text(S.of(context).no_menu_info)), - ], - ), + child: Center(child: Text(S.of(context).no_menu_info)), ); } else { return Container( diff --git a/uni/lib/view/schedule/widgets/schedule_slot.dart b/uni/lib/view/schedule/widgets/schedule_slot.dart index 48c55dcec..f5238c7a1 100644 --- a/uni/lib/view/schedule/widgets/schedule_slot.dart +++ b/uni/lib/view/schedule/widgets/schedule_slot.dart @@ -133,22 +133,17 @@ class SubjectButtonWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - IconButton( - constraints: const BoxConstraints( - minHeight: kMinInteractiveDimension / 3, - minWidth: kMinInteractiveDimension / 3, - ), - icon: const Icon(Icons.open_in_browser), - iconSize: 18, - color: Colors.grey, - alignment: Alignment.centerRight, - tooltip: S.of(context).uc_info, - onPressed: () => _launchUcPage(context), - ), - ], + return IconButton( + constraints: const BoxConstraints( + minHeight: kMinInteractiveDimension / 3, + minWidth: kMinInteractiveDimension / 3, + ), + icon: const Icon(Icons.open_in_browser), + iconSize: 18, + color: Colors.grey, + alignment: Alignment.centerRight, + tooltip: S.of(context).uc_info, + onPressed: () => _launchUcPage(context), ); } } diff --git a/uni/lib/view/settings/widgets/notifications_dialog.dart b/uni/lib/view/settings/widgets/notifications_dialog.dart index 4defadfc2..d71385718 100644 --- a/uni/lib/view/settings/widgets/notifications_dialog.dart +++ b/uni/lib/view/settings/widgets/notifications_dialog.dart @@ -9,14 +9,9 @@ class NotificationsDialog extends StatelessWidget { Widget build(BuildContext context) { return AlertDialog( title: Text(S.of(context).notifications), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - title: Text(S.of(context).fee_notification), - trailing: const TuitionNotificationSwitch(), - ), - ], + content: ListTile( + title: Text(S.of(context).fee_notification), + trailing: const TuitionNotificationSwitch(), ), ); } diff --git a/uni/pubspec.lock b/uni/pubspec.lock index 2e80b7d3d..96c8bfc26 100644 --- a/uni/pubspec.lock +++ b/uni/pubspec.lock @@ -306,7 +306,7 @@ packages: source: hosted version: "2.2.1" custom_lint: - dependency: transitive + dependency: "direct dev" description: name: custom_lint sha256: "7c0aec12df22f9082146c354692056677f1e70bc43471644d1fdb36c6fdda799" diff --git a/uni/pubspec.yaml b/uni/pubspec.yaml index 8d4a9f433..37b7af016 100644 --- a/uni/pubspec.yaml +++ b/uni/pubspec.yaml @@ -67,6 +67,7 @@ dependencies: dev_dependencies: build_runner: ^2.4.8 + custom_lint: ^0.6.4 flutter_launcher_icons: ^0.13.1 flutter_test: sdk: flutter