From 60433208378373983ac74f47ac39def03cf8267b Mon Sep 17 00:00:00 2001 From: Daniele Ricci Date: Sun, 13 Aug 2023 20:16:53 +0200 Subject: [PATCH] fix(flight-log): force reload of log book on resume close #74 --- lib/screens/flight_log/flight_log_screen.dart | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/screens/flight_log/flight_log_screen.dart b/lib/screens/flight_log/flight_log_screen.dart index a3042ff..eaea9e6 100644 --- a/lib/screens/flight_log/flight_log_screen.dart +++ b/lib/screens/flight_log/flight_log_screen.dart @@ -19,7 +19,7 @@ class FlightLogScreen extends StatefulWidget { State createState() => _FlightLogScreenState(); } -class _FlightLogScreenState extends State { +class _FlightLogScreenState extends State with WidgetsBindingObserver { late FToast _fToast; late FlightLogListController _logBookController; late AppConfig _appConfig; @@ -28,6 +28,7 @@ class _FlightLogScreenState extends State { @override void initState() { super.initState(); + WidgetsBinding.instance.addObserver(this); _fToast = FToast(); _fToast.init(context); _logBookController = FlightLogListController(); @@ -46,10 +47,18 @@ class _FlightLogScreenState extends State { 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() {