enhanced_future_builder – Cache FutureBuilder Result without Refreshing FutureBuilder with setState

enhanced_future_builder is a small library which wraps around FutureBuilder to improve its readability. It can also be used as an easy solution to prevent FutureBuilder from keep reloading whenever setState is called.

Simple usage

EnhancedFutureBuilder(
	future: _futureResults(),
	rememberFutureResult: false,
	whenDone: (dynamic data) {
		return Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.center,
          children:[
          	Text(data.toString());
          ],
        );
	},
	whenWaiting: Center(child: Text('Waiting...')),
	whenActive: Center(child: Text('Active...')),
	whenNone: Center(child: Text('Active...')),
);

If you want to cache the result, set rememberFutureResult to true.

Leave a Comment

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close