flutter_lifecycle 0.0.1 copy "flutter_lifecycle: ^0.0.1" to clipboard
flutter_lifecycle: ^0.0.1 copied to clipboard

outdated

Get access to Flutter's life cycle on StatelessWidgets

flutter_lifecycle #

Get access to Flutter's life cycle on StatelessWidgets

Getting Started #

You should ensure that you add the flutter_lifecycle as a dependency in your flutter project.

dependencies:
  flutter_lifecycle: "^0.0.1"

read more at how to install

Usage #


import 'package:flutter/material.dart';
import 'package:flutter_lifecycle/flutter_lifecycle.dart';

class HomePage extends StatelessWidget {
  //on init function
  //pass to the LifeCycleWidget
  Dispose _onInit(BuildContext context) {
    //good to showDialogs only when the widget init
    showDialog(
        context: context,
        builder: (context) => AlertDialog(
              content: Text("Hello from init"),
            ));

    //if you need do something on dispose
    //return a Function()
    return () {
      print("on dispose");
    };
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: LifeCycleWidget(
        //set on init function
        onInit: _onInit,
        //builder function
        builder: (context) {
          return Center(
            child: Text("Home page"),
          );
        },
      ),
    );
  }
}

checkout app source at github

2
likes
0
pub points
37%
popularity

Publisher

unverified uploader

Get access to Flutter's life cycle on StatelessWidgets

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_lifecycle