Refresh the app when opened from background state

 class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingObserver{

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
    FlutterDownloader.registerCallback(downloadCallback, step: 1);
  }

  @override
  void dispose() {
    unbindBackgroundIsolate();
    WidgetsBinding.instance.removeObserver(this);
    super.dispose();
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    if (state == AppLifecycleState.resumed) {
      context.read<FetchAppListBloc>().add(RefreshAppListEvent());
    }
  }

also need:
switch (state) { case AppLifecycleState.resumed: // -- print('Resumed'); break; case AppLifecycleState.inactive: // -- print('Inactive'); break; case AppLifecycleState.paused: // -- print('Paused'); break; case AppLifecycleState.detached: // -- print('Detached'); break; }

Comments