A flutter package that lets you easily add hooks for application lifecycle state. LifecycleMixin uses the AppLifecycleListener and registers methods as hooks.

The list of hooks is:

  • onAppShow
  • onAppHide
  • onAppRestart
  • onAppResume
  • onAppPause
  • onAppInactive
  • onAppDetach
  • onExitAppRequest

Note: Read more about these lifecycle hooks https://api.flutter.dev/flutter/widgets/AppLifecycleListener-class.html

Optionally provides onContextReady that acts like initState but BuildContext is available for use.

Getting Started

Add on pubspec.yaml

    flutterlifecyclehooks: version

Example code

class App extends StatefulWidget {
  _AppState createState() => _AppState();

class _AppState extends State<App> with LifecycleMixin {
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text(

  void onAppLifecycleChange(AppLifecycleState state) {
    setState(() {});

  void onResume() {
    print('did resume');

  void onPause() {
    print('did pause');

Also you can use, LifecycleHooksSubscriber wraps a widget and provides convient arguments for lifecycle hooks.

You can use this if you don't want to polute the namespace of a stateful widget.