flib_lifecycle 1.0.0
flib_lifecycle: ^1.0.0 copied to clipboard

lifecycle library.

About #

一个用来管理生命周期的库,库中的实现逻辑参考了android中的生命周期管理的库

Install #

  • git
  flib_lifecycle:
    git:
      url: git://github.com/zj565061763/flib_lifecycle
      ref: 1.0.0
  • pub
  dependencies:
    flib_lifecycle: ^1.0.0

Example #

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> implements FLifecycleOwner {
  final FLifecycleRegistry _lifecycleRegistry = SimpleLifecycleRegistry();

  @override
  FLifecycle getLifecycle() {
    return _lifecycleRegistry;
  }

  @override
  void initState() {
    super.initState();
    // 分发事件
    _lifecycleRegistry.handleLifecycleEvent(FLifecycleEvent.onCreate);
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }

  @override
  void dispose() {
    super.dispose();
    // 分发事件
    _lifecycleRegistry.handleLifecycleEvent(FLifecycleEvent.onDestroy);
  }
}
0
likes
90
pub points
24%
popularity

Publisher

Unknown

lifecycle library.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flib_lifecycle