Member-only story
Sample test
import 'package:flutter/material.dart';
import 'package:nft/utils/app_log.dart';
class HomePage extends StatefulWidget {
const HomePage({Key key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage>
with WidgetsBindingObserver {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
/// Log app life cycle state
logger.d(state);
}
@override
Widget build(BuildContext context) {
return Container();
}
}
Output
- App is opening
- Press home
flutter: [D] AppLifecycleState.inactive
flutter: [D] AppLifecycleState.paused
- Open app by tap on app icon
flutter: [D] AppLifecycleState.inactive
flutter: [D] AppLifecycleState.resumed
- In recent application (double home tap on iPhone)
flutter: [D] AppLifecycleState.inactive
- Kill app from recent application
flutter: [D] AppLifecycleState.paused
About ‘detached’ state
When the application is in this state, the engine is running without a view. It can either be in the progress of attaching a view when engine was first initializes, or after the view being destroyed due to a Navigator pop. -Flutter-
@nhancv
nhancv.com