Skip to content

Commit

Permalink
chore: upgrade Flutter and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-athome committed Nov 26, 2024
1 parent 5827de2 commit ae374e8
Show file tree
Hide file tree
Showing 14 changed files with 365 additions and 268 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:

env:
flutter_version: '3.16.9'
flutter_version: '3.24.5'

jobs:
test-build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:

env:
flutter_version: '3.16.9'
flutter_version: '3.24.5'

jobs:
# Since Fastlane also builds, there is no way to split jobs without sacrificing build time
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:

env:
flutter_version: '3.16.9'
flutter_version: '3.24.5'

jobs:
test-build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:

env:
flutter_version: '3.16.9'
flutter_version: '3.24.5'

jobs:
test-build:
Expand Down
8 changes: 6 additions & 2 deletions lib/helpers/future_progress_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ class _FutureProgressDialogState extends State<FutureProgressDialog> {
void initState() {
super.initState();
widget.future.then((val) {
Navigator.of(context).pop(val);
if (mounted) {
Navigator.of(context).pop(val);
}
}).catchError((e) {
Navigator.of(context).pop();
if (mounted) {
Navigator.of(context).pop();
}
});
}

Expand Down
6 changes: 4 additions & 2 deletions lib/helpers/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ Future<void> showError(BuildContext context, String text) {
Future<bool> openUrl(BuildContext context, String url) async {
return launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication)
.catchError((_) {
// TODO i18n
showError(context, 'Cannot open a browser.');
if (context.mounted) {
// TODO i18n
showError(context, 'Cannot open a browser.');
}
return false;
});
}
Expand Down
50 changes: 31 additions & 19 deletions lib/screens/about/about_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class _AboutScreenState extends State<AboutScreen> {
return aircraftData;
}).catchError((error, StackTrace? stacktrace) {
_log.info('DOWNLOAD ERROR', error, stacktrace);
if (!context.mounted) {
return null;
}

// TODO specialize exceptions (e.g. network errors, others...)
final String message;
if (error is TimeoutException) {
Expand All @@ -74,26 +78,32 @@ class _AboutScreenState extends State<AboutScreen> {
message = getExceptionMessage(error);
}

Future.delayed(Duration.zero, () => showError(context, message));
Future.delayed(Duration.zero, () {
if (context.mounted) {
return showError(context, message);
}
});
return null;
});

showPlatformDialog(
context: context,
builder: (context) {
return FutureProgressDialog(
downloadTask,
message: isCupertino(context)
? null
: Text(AppLocalizations.of(context)!
.addAircraft_dialog_downloading),
);
},
).then((value) async {
if (value != null) {
// TODO maybe notify the user (e.g. toast)?
}
});
if (context.mounted) {
showPlatformDialog(
context: context,
builder: (context) {
return FutureProgressDialog(
downloadTask,
message: isCupertino(context)
? null
: Text(AppLocalizations.of(context)!
.addAircraft_dialog_downloading),
);
},
).then((value) async {
if (value != null) {
// TODO maybe notify the user (e.g. toast)?
}
});
}
}
});
}
Expand All @@ -107,8 +117,10 @@ class _AboutScreenState extends State<AboutScreen> {
okCallback: () {
_appConfig.pilotName = null;
_appConfig.setCurrentAircraft(null).whenComplete(() {
Navigator.of(context, rootNavigator: true)
.popAndPushNamed('aircraft-data');
if (context.mounted) {
Navigator.of(context, rootNavigator: true)
.popAndPushNamed('aircraft-data');
}
});
},
);
Expand Down
10 changes: 9 additions & 1 deletion lib/screens/aircraft_select/aircraft_data_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ class _SetAircraftDataScreenState extends State<SetAircraftDataScreen> {
return aircraftData;
}).catchError((error, StackTrace? stacktrace) {
_log.info('DOWNLOAD ERROR', error, stacktrace);
if (!context.mounted) {
return null;
}

// TODO specialize exceptions (e.g. network errors, others...)
final String message;
if (error is TimeoutException) {
Expand All @@ -96,7 +100,11 @@ class _SetAircraftDataScreenState extends State<SetAircraftDataScreen> {
message = getExceptionMessage(error);
}

Future.delayed(Duration.zero, () => showError(context, message));
Future.delayed(Duration.zero, () {
if (context.mounted) {
return showError(context, message);
}
});
return null;
});

Expand Down
21 changes: 17 additions & 4 deletions lib/screens/book_flight/book_flight_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,13 @@ class _BookFlightModalState extends State<BookFlightModal> {
.timeout(kNetworkRequestTimeout)
.then((conflict) {
if (conflict) {
throw Exception(AppLocalizations.of(context)!
.bookFlightModal_error_timeConflict);
if (context.mounted) {
throw Exception(AppLocalizations.of(context)!
.bookFlightModal_error_timeConflict);
}
else {
return Future.value(null);
}
} else {
return (_isEditing
? _service.updateBooking(event)
Expand All @@ -415,6 +420,10 @@ class _BookFlightModalState extends State<BookFlightModal> {
.then((value) => Future<FlightBooking?>.value(value))
.catchError((error, StackTrace stacktrace) {
_log.warning('SAVE ERROR', error, stacktrace);
if (!context.mounted) {
return null;
}

final String message;
// TODO specialize exceptions (e.g. network errors, others...)
if (error is TimeoutException) {
Expand All @@ -439,7 +448,7 @@ class _BookFlightModalState extends State<BookFlightModal> {
AppLocalizations.of(context)!.bookFlightModal_dialog_working),
),
).then((value) {
if (value != null) {
if (value != null && context.mounted) {
Navigator.of(context).pop(value);
}
});
Expand Down Expand Up @@ -473,6 +482,10 @@ class _BookFlightModalState extends State<BookFlightModal> {
.then((value) => Future<DeletedFlightBooking?>.value(value))
.catchError((error, StackTrace stacktrace) {
_log.warning('DELETE ERROR', error, stacktrace);
if (!context.mounted) {
return null;
}

final String message;
// TODO specialize exceptions (e.g. network errors, others...)
if (error is TimeoutException) {
Expand All @@ -496,7 +509,7 @@ class _BookFlightModalState extends State<BookFlightModal> {
AppLocalizations.of(context)!.bookFlightModal_dialog_working),
),
).then((value) {
if (value != null) {
if (value != null && context.mounted) {
Navigator.of(context, rootNavigator: true).pop(value);
}
});
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/book_flight/book_flight_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ class BookFlightScreenState extends State<BookFlightScreen> {
fullscreenDialog: true,
);
Navigator.of(context, rootNavigator: true).push(route).then((result) {
if (result != null) {
if (result != null && context.mounted) {
final String message;
if (event == null) {
message =
Expand Down
12 changes: 10 additions & 2 deletions lib/screens/flight_log/flight_log_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,10 @@ class _FlightLogModalState extends State<FlightLogModal> {
.then((value) => Future<FlightLogItem?>.value(value))
.catchError((error, StackTrace stacktrace) {
_log.warning('SAVE ERROR', error, stacktrace);
if (!context.mounted) {
return null;
}

final String message;
// TODO specialize exceptions (e.g. network errors, others...)
if (error is TimeoutException) {
Expand All @@ -664,7 +668,7 @@ class _FlightLogModalState extends State<FlightLogModal> {
: Text(AppLocalizations.of(context)!.flightLogModal_dialog_working),
),
).then((value) {
if (value != null) {
if (value != null && context.mounted) {
Navigator.of(context).pop(value);
}
});
Expand Down Expand Up @@ -699,6 +703,10 @@ class _FlightLogModalState extends State<FlightLogModal> {
.then((value) => Future<FlightLogItem?>.value(value))
.catchError((error, StackTrace stacktrace) {
_log.warning('DELETE ERROR', error, stacktrace);
if (!context.mounted) {
return null;
}

final String message;
// TODO specialize exceptions (e.g. network errors, others...)
if (error is TimeoutException) {
Expand All @@ -721,7 +729,7 @@ class _FlightLogModalState extends State<FlightLogModal> {
: Text(AppLocalizations.of(context)!.flightLogModal_dialog_working),
),
).then((value) {
if (value != null) {
if (value != null && context.mounted) {
Navigator.of(context, rootNavigator: true).pop(value);
}
});
Expand Down
4 changes: 4 additions & 0 deletions lib/screens/flight_log/flight_log_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class _FlightLogScreenState extends State<FlightLogScreen> with WidgetsBindingOb
);
Navigator.of(context, rootNavigator: true).push(route).then((result) {
if (result != null) {
if (!context.mounted) {
return;
}

final String message;
if (item == null) {
message =
Expand Down
Loading

0 comments on commit ae374e8

Please sign in to comment.