lifecycle_widget 1.0.0+3
lifecycle_widget: ^1.0.0+3 copied to clipboard

Flutter Android iOS Linux macOS web Windows

Flutter widget with lifecycle methods

Lifecycle widget #

Flutter widget with lifecycle methods GitHub stars Twitter Follow

Installation #

Add dependency to pubspec.yaml

  lifecycle_widget: ^1.0.0

Run in your terminal

flutter packages get

Example #

class TestWidget extends LifecycleWidget {
  final int number;

  const TestWidget({Key key, this.number}) : super(key: key);

  void notify(BuildContext context, String text) {
      content: Text(text),

  void didMount(BuildContext context) {
    notify(context, 'did mount');

  void didUpdate(
    BuildContext context,
    covariant TestWidget oldWidget,
    covariant TestWidget widget,
  ) {
    notify(context, 'update ${oldWidget.number} => ${widget.number}');
    super.didUpdate(context, oldWidget, widget);

  void willUnmount(BuildContext context) {
    print('will unmount');

  Widget build(BuildContext context) {
    return Center(child: Text("number is $number"));

License #

MIT GitHub stars Twitter Follow