Skip to content
pubscout

flutter_fgbg

0.8.0, released 8 months ago by an unverified publisher

Detects when the Flutter app goes to the background or foreground at the app level.

$ flutter pub add flutter_fgbg
Source repository

What it does

Detects true app-level background and foreground events rather than individual Activity or ViewController state changes. Provides a built-in widget and a stream to listen for lifecycle transitions.

AI-written summary of version 0.8.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to detect true app-level background and foreground transitions
  • You want to avoid false triggers caused by opening new activities, view controllers, or FaceID prompts

Skip it when

  • You only need standard widget binding observations for embedding activities

Strengths

  • Avoids false positives from native container changes like FaceID prompts
  • Provides both a reactive widget and an event stream
  • Includes ignoreWhile API to bypass specific events like image picking

Weaknesses

  • Can be triggered by actions like picking an image on newer Android versions that open external apps
  • Requires a clean build after adding to integrate native code

Setup

Kind
Plugin (native code)
Effort
Low
Code generation
No
Direct dependencies
0

Requires a clean build to integrate the plugin native code into the app.

FGBGNotifier(
    onEvent: (event) {
        print(event);
    },
    child: Container(),
)

Alternatives

Packages that do the same job and could replace flutter_fgbg.

Works with

Packages commonly used together with flutter_fgbg: ones it builds on, ones built on it, and its own family.