You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When transitioning a Flutter app to the background, the AppLifecycleState.paused state is not detected on Android devices, while it is correctly detected on iOS. On Android, the lifecycle only reaches AppLifecycleState.inactive, omitting the paused state. This inconsistency between platforms can lead to issues in handling app lifecycle states in Flutter applications using flutter_hooks.
To Reproduce
Use the following Flutter code to monitor app lifecycle states:
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Debug service listening on ws://127.0.0.1:50008/retjf42mpLQ=/ws
Syncing files to device sdk gphone64 arm64...
I/flutter ( 9338): appLifecycle=AppLifecycleState.resumed
I/flutter ( 9338): appLifecycle=AppLifecycleState.inactive
console(iOS)
Launching lib/main.dart on iPhone 15 Pro Max in debug mode...
Running Xcode build...
Xcode build done. 18.5s
Debug service listening on ws://127.0.0.1:64621/OFX7kmx7qO0=/ws
Syncing files to device iPhone 15 Pro Max...
flutter: appLifecycle=AppLifecycleState.resumed
flutter: appLifecycle=AppLifecycleState.inactive
flutter: appLifecycle=AppLifecycleState.paused
Run the app on an iOS device and transition the app to the background. The console logs will correctly show the lifecycle states transitioning through resumed, inactive, and paused.
Run the same app on an Android device and repeat the process. The console logs will only show resumed and inactive, missing the paused state.
appLifecycle.mov
Expected behavior
The expected behavior is that on both iOS and Android platforms, transitioning the app to the background should consistently trigger AppLifecycleState.resumed, AppLifecycleState.inactive, and AppLifecycleState.paused in that order.
The text was updated successfully, but these errors were encountered:
I would like to detect AppLifecycleState because I want to cancel the Firestore snapshot once the app has moved to the background. (I'm using cloud_firestore_odm and riverpod.)
The expected behavior is that on both iOS and Android platforms, transitioning the app to the background should consistently trigger AppLifecycleState.resumed, AppLifecycleState.inactive, and AppLifecycleState.paused in that order.
It is not possible to make this guarantee
Flutter decides when it invoked build. It could very well be that two life-cycle changes happen at once, before build could be invoked.
This would swallow the first event.
I would like to detect AppLifecycleState because I want to cancel the Firestore snapshot once the app has moved to the background. (I'm using cloud_firestore_odm and riverpod.)
Describe the bug
When transitioning a Flutter app to the background, the AppLifecycleState.paused state is not detected on Android devices, while it is correctly detected on iOS. On Android, the lifecycle only reaches AppLifecycleState.inactive, omitting the paused state. This inconsistency between platforms can lead to issues in handling app lifecycle states in Flutter applications using flutter_hooks.
To Reproduce
Use the following Flutter code to monitor app lifecycle states:
Sample Code
pubspec.yaml
console(Android)
console(iOS)
Launching lib/main.dart on iPhone 15 Pro Max in debug mode... Running Xcode build... Xcode build done. 18.5s Debug service listening on ws://127.0.0.1:64621/OFX7kmx7qO0=/ws Syncing files to device iPhone 15 Pro Max... flutter: appLifecycle=AppLifecycleState.resumed flutter: appLifecycle=AppLifecycleState.inactive flutter: appLifecycle=AppLifecycleState.paused
appLifecycle.mov
Expected behavior
The expected behavior is that on both iOS and Android platforms, transitioning the app to the background should consistently trigger AppLifecycleState.resumed, AppLifecycleState.inactive, and AppLifecycleState.paused in that order.
The text was updated successfully, but these errors were encountered: