Skip to content

Commit

Permalink
fix(flight-log): force reload of log book on resume
Browse files Browse the repository at this point in the history
close #74
  • Loading branch information
daniele-athome committed Aug 13, 2023
1 parent ae4422b commit 6043320
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/screens/flight_log/flight_log_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FlightLogScreen extends StatefulWidget {
State<FlightLogScreen> createState() => _FlightLogScreenState();
}

class _FlightLogScreenState extends State<FlightLogScreen> {
class _FlightLogScreenState extends State<FlightLogScreen> with WidgetsBindingObserver {
late FToast _fToast;
late FlightLogListController _logBookController;
late AppConfig _appConfig;
Expand All @@ -28,6 +28,7 @@ class _FlightLogScreenState extends State<FlightLogScreen> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
_fToast = FToast();
_fToast.init(context);
_logBookController = FlightLogListController();
Expand All @@ -46,10 +47,18 @@ class _FlightLogScreenState extends State<FlightLogScreen> {
super.didUpdateWidget(oldWidget);
}

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) {
_logBookController.reset();
}
}

@override
void dispose() {
super.dispose();
WidgetsBinding.instance.removeObserver(this);
_logBookController.removeListener(_logBookListChanged);
super.dispose();
}

void _logBookListChanged() {
Expand Down

0 comments on commit 6043320

Please sign in to comment.