From c854aacd63ed332580ac5c579e8712c273295bd9 Mon Sep 17 00:00:00 2001 From: Daniele Ricci Date: Thu, 16 Nov 2023 20:45:08 +0100 Subject: [PATCH] chore: fix analysis issues --- lib/helpers/cupertinoplus.dart | 18 +++++++-------- lib/helpers/digit_display.dart | 23 ++++++++----------- lib/helpers/future_progress_dialog.dart | 4 ++-- lib/helpers/list_tiles.dart | 8 +++---- lib/helpers/pilot_select_list.dart | 4 ++-- lib/helpers/utils.dart | 14 +++++------ lib/main.dart | 2 +- lib/screens/about/about_screen.dart | 9 ++++---- lib/screens/activities/activities_list.dart | 9 ++++---- lib/screens/activities/activities_screen.dart | 2 +- .../aircraft_select/aircraft_data_screen.dart | 2 +- .../book_flight/book_flight_modal.dart | 7 +++--- .../book_flight/book_flight_screen.dart | 2 +- lib/screens/flight_log/flight_log_list.dart | 4 ++-- lib/screens/flight_log/flight_log_modal.dart | 6 ++--- lib/screens/flight_log/flight_log_screen.dart | 2 +- lib/screens/flight_log/hour_widget.dart | 12 +++++----- lib/screens/main/main_screen.dart | 9 ++++---- .../pilot_select/pilot_select_screen.dart | 2 +- 19 files changed, 67 insertions(+), 72 deletions(-) diff --git a/lib/helpers/cupertinoplus.dart b/lib/helpers/cupertinoplus.dart index 786edb6..b382330 100644 --- a/lib/helpers/cupertinoplus.dart +++ b/lib/helpers/cupertinoplus.dart @@ -54,11 +54,11 @@ Widget buildCupertinoFormRowDivider(BuildContext context, bool shortDivider) { /// An [InkWell] equivalent for Cupertino. Simply colors the background of the container. class CupertinoInkWell extends StatefulWidget { const CupertinoInkWell({ - Key? key, + super.key, required this.child, required this.onPressed, this.backgroundColor, - }) : super(key: key); + }); final Widget child; final VoidCallback? onPressed; @@ -123,9 +123,9 @@ class _CupertinoInkWellState extends State { /// A standard-sized container for a [CupertinoFormRow] child. class CupertinoFormRowContainer extends StatelessWidget { const CupertinoFormRowContainer({ - Key? key, + super.key, this.child, - }) : super(key: key); + }); final Widget? child; @@ -143,7 +143,7 @@ class CupertinoFormRowContainer extends StatelessWidget { /// A button-like [CupertinoFormRow]. Heavily inspired by [CupertinoButton]. class CupertinoFormButtonRow extends StatefulWidget { const CupertinoFormButtonRow({ - Key? key, + super.key, required this.child, this.prefix, this.padding, @@ -151,7 +151,7 @@ class CupertinoFormButtonRow extends StatefulWidget { this.error, this.pressedOpacity = 0.4, required this.onPressed, - }) : super(key: key); + }); final Widget? prefix; final EdgeInsetsGeometry? padding; @@ -193,7 +193,7 @@ class _CupertinoFormButtonRowState extends State class CupertinoDateTimeFormFieldRow extends FormField { // TODO other constructor parameters CupertinoDateTimeFormFieldRow({ - Key? key, + super.key, this.prefix, this.controller, this.helper, @@ -202,13 +202,11 @@ class CupertinoDateTimeFormFieldRow extends FormField { required this.doneButtonText, DateTime? initialValue, void Function(DateTime value, DateTime oldValue)? onChanged, - FormFieldSetter? onSaved, + super.onSaved, }) : assert(showDate || showTime, 'showDate and showTime cannot be both false!'), super( - key: key, initialValue: controller?.value ?? initialValue ?? DateTime.now(), - onSaved: onSaved, builder: (FormFieldState field) { void onTapDateHandler() { showCupertinoModalPopup( diff --git a/lib/helpers/digit_display.dart b/lib/helpers/digit_display.dart index e976a10..6fc1ba6 100644 --- a/lib/helpers/digit_display.dart +++ b/lib/helpers/digit_display.dart @@ -10,17 +10,14 @@ final NumberFormat kHoursFormatter = NumberFormat("00000.00"); class DigitDisplayFormTextField extends FormField { DigitDisplayFormTextField({ - Key? key, + super.key, DigitDisplayController? controller, - FormFieldSetter? onSaved, - FormFieldValidator? validator, + super.onSaved, + super.validator, double fontSize = _kDefaultDigitFontSize, EdgeInsetsGeometry padding = _kDefaultDigitPadding, }) : super( - key: key, - onSaved: onSaved, initialValue: controller?.value.number, - validator: validator, builder: (field) { return DigitDisplayTextField( controller: controller, @@ -33,13 +30,13 @@ class DigitDisplayFormTextField extends FormField { class DigitDisplayTextField extends StatefulWidget { const DigitDisplayTextField({ - Key? key, + super.key, this.controller, this.fontSize = _kDefaultDigitFontSize, this.errorText, this.padding = _kDefaultDigitPadding, this.enabled = false, - }) : super(key: key); + }); final DigitDisplayController? controller; final double fontSize; @@ -145,14 +142,13 @@ class DigitDisplay { class SingleDigitText extends StatelessWidget { const SingleDigitText({ - Key? key, + super.key, required this.digit, this.decimal = false, this.fontSize = _kDefaultDigitFontSize, this.active = false, this.onTap, - }) : assert(digit >= 0 && digit <= 9), - super(key: key); + }) : assert(digit >= 0 && digit <= 9); final int digit; final bool decimal; @@ -172,13 +168,14 @@ class SingleDigitText extends StatelessWidget { class _DigitText extends StatelessWidget { const _DigitText({ - Key? key, + // ignore: unused_element + super.key, required this.text, this.alternate = false, this.fontSize = _kDefaultDigitFontSize, this.active = false, this.onTap, - }) : super(key: key); + }); final String text; final bool alternate; diff --git a/lib/helpers/future_progress_dialog.dart b/lib/helpers/future_progress_dialog.dart index 7293f8e..b9c5cd6 100644 --- a/lib/helpers/future_progress_dialog.dart +++ b/lib/helpers/future_progress_dialog.dart @@ -39,12 +39,12 @@ class FutureProgressDialog extends StatefulWidget { const FutureProgressDialog( this.future, { - Key? key, + super.key, this.decoration, this.opacity = 1.0, this.progress, this.message, - }) : super(key: key); + }); @override State createState() => _FutureProgressDialogState(); diff --git a/lib/helpers/list_tiles.dart b/lib/helpers/list_tiles.dart index 7351c14..2e258c7 100644 --- a/lib/helpers/list_tiles.dart +++ b/lib/helpers/list_tiles.dart @@ -13,13 +13,13 @@ class DateListTile extends StatelessWidget { static final DateFormat _dateFormatter = DateFormat.yMEd(); const DateListTile({ - Key? key, + super.key, required this.controller, this.onDateSelected, // ignore: unused_element this.showIcon = true, this.textStyle, - }) : super(key: key); + }); @override Widget build(BuildContext context) { @@ -79,12 +79,12 @@ class DateTimeListTile extends StatelessWidget { static final DateFormat _dateFormatter = DateFormat.yMEd(); const DateTimeListTile({ - Key? key, + super.key, required this.controller, required this.onDateSelected, required this.onTimeSelected, this.showIcon = true, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/helpers/pilot_select_list.dart b/lib/helpers/pilot_select_list.dart index b2c9d71..03eda9d 100644 --- a/lib/helpers/pilot_select_list.dart +++ b/lib/helpers/pilot_select_list.dart @@ -11,12 +11,12 @@ class PilotSelectList extends StatelessWidget { final Function(String selected) onSelection; const PilotSelectList({ - Key? key, + super.key, required this.pilotNames, required this.avatarProvider, required this.onSelection, this.selectedName, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/helpers/utils.dart b/lib/helpers/utils.dart index 81d35be..9ab4749 100644 --- a/lib/helpers/utils.dart +++ b/lib/helpers/utils.dart @@ -251,7 +251,7 @@ class DownloadProvider extends ChangeNotifier { /// A basic controller for date and time pickers. class DateTimePickerController extends ValueNotifier { - DateTimePickerController(DateTime? value) : super(value); + DateTimePickerController(super.value); } /// Basic layout for indicating that an exception occurred. @@ -261,8 +261,8 @@ class FirstPageExceptionIndicator extends StatelessWidget { required this.title, this.message, this.onTryAgain, - Key? key, - }) : super(key: key); + super.key, + }); final String title; final String? message; @@ -342,8 +342,8 @@ class FirstPageExceptionIndicator extends StatelessWidget { class FooterTile extends StatelessWidget { const FooterTile({ required this.child, - Key? key, - }) : super(key: key); + super.key, + }); final Widget child; @@ -360,10 +360,10 @@ class FooterTile extends StatelessWidget { /// Forked from [infinite\_scroll\_pagination]. class NewPageErrorIndicator extends StatelessWidget { const NewPageErrorIndicator({ - Key? key, + super.key, required this.message, this.onTap, - }) : super(key: key); + }); final String message; final VoidCallback? onTap; diff --git a/lib/main.dart b/lib/main.dart index 3e67d77..b630427 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -76,7 +76,7 @@ Future main() async { } class MyApp extends StatefulWidget { - const MyApp({Key? key}) : super(key: key); + const MyApp({super.key}); @override State createState() => _MyAppState(); diff --git a/lib/screens/about/about_screen.dart b/lib/screens/about/about_screen.dart index 67f2d8d..570b14c 100644 --- a/lib/screens/about/about_screen.dart +++ b/lib/screens/about/about_screen.dart @@ -20,7 +20,7 @@ final Logger _log = Logger((AboutScreen).toString()); // TODO convert to stateless widget if using only AppConfig class AboutScreen extends StatefulWidget { - const AboutScreen({Key? key}) : super(key: key); + const AboutScreen({super.key}); @override State createState() => _AboutScreenState(); @@ -358,8 +358,7 @@ class _AboutScreenState extends State { leading: CircleAvatar( foregroundImage: _appConfig.getPilotAvatar(e)), title: Text(e), - )) - .toList(growable: false), + )), HeaderListTile(AppLocalizations.of(context)!.appName), ListTile( contentPadding: const EdgeInsets.symmetric(horizontal: 20), @@ -514,9 +513,9 @@ class _AboutScreenState extends State { class HeaderListTile extends StatelessWidget { const HeaderListTile( this.text, { - Key? key, + super.key, this.first = false, - }) : super(key: key); + }); /// The text to be displayed. final String text; diff --git a/lib/screens/activities/activities_list.dart b/lib/screens/activities/activities_list.dart index 6e5a7ad..b983589 100644 --- a/lib/screens/activities/activities_list.dart +++ b/lib/screens/activities/activities_list.dart @@ -17,10 +17,10 @@ class ActivitiesList extends StatefulWidget { final ActivitiesService activitiesService; const ActivitiesList({ - Key? key, + super.key, required this.controller, required this.activitiesService, - }) : super(key: key); + }); @override State createState() => _ActivitiesListState(); @@ -205,9 +205,10 @@ class _EntryListItem extends StatelessWidget { static final DateFormat _dateFormatter = DateFormat.yMd(); const _EntryListItem({ - Key? key, + // ignore: unused_element + super.key, required this.entry, - }) : super(key: key); + }); final ActivityEntry entry; diff --git a/lib/screens/activities/activities_screen.dart b/lib/screens/activities/activities_screen.dart index 53d8823..511a6e1 100644 --- a/lib/screens/activities/activities_screen.dart +++ b/lib/screens/activities/activities_screen.dart @@ -11,7 +11,7 @@ import '../../services/activities_services.dart'; import 'activities_list.dart'; class ActivitiesScreen extends StatefulWidget { - const ActivitiesScreen({Key? key}) : super(key: key); + const ActivitiesScreen({super.key}); @override State createState() => _ActivitiesScreenState(); diff --git a/lib/screens/aircraft_select/aircraft_data_screen.dart b/lib/screens/aircraft_select/aircraft_data_screen.dart index 2a04e15..11256e8 100644 --- a/lib/screens/aircraft_select/aircraft_data_screen.dart +++ b/lib/screens/aircraft_select/aircraft_data_screen.dart @@ -17,7 +17,7 @@ import '../../helpers/utils.dart'; final Logger _log = Logger((AircraftData).toString()); class SetAircraftDataScreen extends StatefulWidget { - const SetAircraftDataScreen({Key? key}) : super(key: key); + const SetAircraftDataScreen({super.key}); @override State createState() => _SetAircraftDataScreenState(); diff --git a/lib/screens/book_flight/book_flight_modal.dart b/lib/screens/book_flight/book_flight_modal.dart index 5947480..0c62b91 100644 --- a/lib/screens/book_flight/book_flight_modal.dart +++ b/lib/screens/book_flight/book_flight_modal.dart @@ -21,7 +21,7 @@ import '../../services/book_flight_services.dart'; final Logger _log = Logger((FlightBooking).toString()); class BookFlightModal extends StatefulWidget { - const BookFlightModal(this.event, {Key? key}) : super(key: key); + const BookFlightModal(this.event, {super.key}); final FlightBooking event; @@ -526,10 +526,11 @@ class _SunTimesListTile extends StatelessWidget { final DateTime sunset; const _SunTimesListTile({ - Key? key, + // ignore: unused_element + super.key, required this.sunrise, required this.sunset, - }) : super(key: key); + }); Color? _getIconColor(BuildContext context) => getBrightness(context) == Brightness.dark ? null : Colors.black45; diff --git a/lib/screens/book_flight/book_flight_screen.dart b/lib/screens/book_flight/book_flight_screen.dart index 03857db..0943f4e 100644 --- a/lib/screens/book_flight/book_flight_screen.dart +++ b/lib/screens/book_flight/book_flight_screen.dart @@ -34,7 +34,7 @@ Color _resolveEventBackgroundColor(BuildContext context) => const _kEventDefaultDuration = Duration(hours: 1); class BookFlightScreen extends StatefulWidget { - const BookFlightScreen({Key? key}) : super(key: key); + const BookFlightScreen({super.key}); @override BookFlightScreenState createState() => BookFlightScreenState(); diff --git a/lib/screens/flight_log/flight_log_list.dart b/lib/screens/flight_log/flight_log_list.dart index e6f64d6..c8b43e0 100644 --- a/lib/screens/flight_log/flight_log_list.dart +++ b/lib/screens/flight_log/flight_log_list.dart @@ -16,11 +16,11 @@ final Logger _log = Logger((FlightLogItem).toString()); class FlightLogList extends StatefulWidget { const FlightLogList({ - Key? key, + super.key, required this.controller, required this.logBookService, required this.onTapItem, - }) : super(key: key); + }); final FlightLogListController controller; final FlightLogBookService logBookService; diff --git a/lib/screens/flight_log/flight_log_modal.dart b/lib/screens/flight_log/flight_log_modal.dart index 365f494..95c995c 100644 --- a/lib/screens/flight_log/flight_log_modal.dart +++ b/lib/screens/flight_log/flight_log_modal.dart @@ -48,7 +48,7 @@ num _parseFuelPrice(String text) => roundDouble(_fuelPriceFormatter.parse(text), _kFuelPriceDecimals); class FlightLogModal extends StatefulWidget { - const FlightLogModal(this.item, {Key? key}) : super(key: key); + const FlightLogModal(this.item, {super.key}); final FlightLogItem item; @@ -750,12 +750,12 @@ class _MaterialFuelPriceSelector extends StatelessWidget { /// Builds a fuel price text input field. /// onChanged will give the total cost. const _MaterialFuelPriceSelector.totalCost({ - Key? key, + super.key, // ignore: unused_element this.onChanged, required this.currencySymbol, required this.textController, - }) : super(key: key); + }); final TextEditingController? textController; final void Function(num? value)? onChanged; diff --git a/lib/screens/flight_log/flight_log_screen.dart b/lib/screens/flight_log/flight_log_screen.dart index eaea9e6..0029af3 100644 --- a/lib/screens/flight_log/flight_log_screen.dart +++ b/lib/screens/flight_log/flight_log_screen.dart @@ -13,7 +13,7 @@ import 'flight_log_list.dart'; import 'flight_log_modal.dart'; class FlightLogScreen extends StatefulWidget { - const FlightLogScreen({Key? key}) : super(key: key); + const FlightLogScreen({super.key}); @override State createState() => _FlightLogScreenState(); diff --git a/lib/screens/flight_log/hour_widget.dart b/lib/screens/flight_log/hour_widget.dart index 26f6e9a..3dcf2b9 100644 --- a/lib/screens/flight_log/hour_widget.dart +++ b/lib/screens/flight_log/hour_widget.dart @@ -10,12 +10,12 @@ import '../../helpers/digit_display.dart'; class HourListTile extends StatefulWidget { const HourListTile({ - Key? key, + super.key, required this.controller, required this.hintText, this.showIcon = true, this.onTap, - }) : super(key: key); + }); final DigitDisplayController controller; final String hintText; @@ -99,11 +99,11 @@ class _HourListTileState extends State { class CupertinoHourFormRow extends StatefulWidget { const CupertinoHourFormRow({ - Key? key, + super.key, required this.controller, required this.hintText, this.onTap, - }) : super(key: key); + }); final DigitDisplayController controller; final String hintText; @@ -192,12 +192,12 @@ class _CupertinoHourFormRowState extends State { class HourMeterDialog extends StatefulWidget { const HourMeterDialog({ - Key? key, + super.key, required this.initialValue, this.onChanged, this.onConfirm, this.onCancel, - }) : super(key: key); + }); final num initialValue; final Function(num value)? onChanged; diff --git a/lib/screens/main/main_screen.dart b/lib/screens/main/main_screen.dart index 7147dfc..4b66c0a 100644 --- a/lib/screens/main/main_screen.dart +++ b/lib/screens/main/main_screen.dart @@ -25,21 +25,20 @@ class MainNavigation extends StatefulWidget { // TODO other services one day... - const MainNavigation(this.appConfig, {Key? key}) + const MainNavigation(this.appConfig, {super.key}) : bookFlightCalendarService = null, flightLogBookService = null, - activitiesService = null, - super(key: key); + activitiesService = null; /// Mainly for integration testing. @visibleForTesting const MainNavigation.withServices( this.appConfig, { - Key? key, + super.key, this.bookFlightCalendarService, this.flightLogBookService, this.activitiesService, - }) : super(key: key); + }); @override State createState() => _MainNavigationState(); diff --git a/lib/screens/pilot_select/pilot_select_screen.dart b/lib/screens/pilot_select/pilot_select_screen.dart index 7424c8f..d0fdf46 100644 --- a/lib/screens/pilot_select/pilot_select_screen.dart +++ b/lib/screens/pilot_select/pilot_select_screen.dart @@ -10,7 +10,7 @@ import '../../helpers/pilot_select_list.dart'; import '../../helpers/utils.dart'; class PilotSelectScreen extends StatelessWidget { - const PilotSelectScreen({Key? key}) : super(key: key); + const PilotSelectScreen({super.key}); @override Widget build(BuildContext context) {