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

outdated

Flutter didbuildcallback

Widget Did Build #

When you find your self wanting to run a function once with context after a widget build has been completed, the current flutter system makes it difficult to accomplish.

This is a simple library that makes it easy to run a function that takes in a context and runs once after the widget is built. Similar to componentDidMount in React.

Usage #

  1. Change you state class from
class _MyAppState extends State<MyApp> {
  
} 

to

class _MyAppState extends DidBuildState<MyApp> {
  
}
  1. Import the plugin
import 'package:widget_did_build/widget_did_build.dart';
  1. Add and override the didBuildMethod in your state class

  2. Done.


This is what you state class will look like in the end


class _MyAppState extends DidBuildState<MyApp> { // Using DidBuildState instead of State

  @override
  void didBuild(BuildContext context) { // overriding and implement the didBuild method
    // call your method here 
  }

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

3
likes
0
pub points
24%
popularity

Publisher

unverified uploader

Flutter didbuildcallback

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on widget_did_build