lifecycle_mixin 1.0.0 copy "lifecycle_mixin: ^1.0.0" to clipboard
lifecycle_mixin: ^1.0.0 copied to clipboard

This package allows you to manage your project using lifecycle through a Mixin.

Lifecycle Mixin #

This package allows you to manage your project using lifecycle through a Mixin. To much similar as Android's Lifecycle system and an improved implementation of focus_detector by EdsonBueno.

Features #

You'll be able to manage your app with these functions:

  • onResume
  • onSuspending
  • onForegroundResume
  • onForegroundSuspending
  • onBackgroundResume
  • onBackgroundSuspending
  • onLayoutComplete

Usage #

To use this package in your StatefulWidget, substitute your build() method with onBuild() and use the LifecycleMixin available from the package.

class YourPage extends StatefulWidget {
  const YourPage({super.key});

  @override
  State<YourPage> createState() => _YourPageState();
}

class _YourPageState extends State<YourPage> with LifecycleMixin {
  @override
  void onResume() {
    // TODO: implement onResume
    super.onResume();
  }

  @override
  void onSuspending() {
    // TODO: implement onSuspending
    super.onSuspending();
  }

  @override
  void onBackgroundResume() {
    // TODO: implement onBackgroundResume
    super.onBackgroundResume();
  }

  @override
  void onBackgroundSuspending() {
    // TODO: implement onBackgroundSuspending
    super.onBackgroundSuspending();
  }

  @override
  void onForegroundResume() {
    // TODO: implement onForegroundResume
    super.onForegroundResume();
  }

  @override
  void onForegroundSuspending() {
    // TODO: implement onForegroundSuspending
    super.onForegroundSuspending();
  }

  @override
  void onLayoutComplete() {
    // TODO: implement onLayoutComplete
    super.onLayoutComplete();
  }

  @override
  Widget onBuild() {
    return Container();
  }
}
2
likes
140
pub points
51%
popularity

Publisher

unverified uploader

This package allows you to manage your project using lifecycle through a Mixin.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, visibility_detector

More

Packages that depend on lifecycle_mixin