FutureBuilder and Snapshot in Flutter_bloc package

Issue

How do i implement futurebuilder and snapshot in blocbuilder by using flutter_bloc package. I am a bit beginner in bloc, so i need an example for futurebuilder in bloc.

Solution

Please add more details of what you are trying to do. FutureBuilder is a widget so you can return it inside of the builder property of BlocBuilder like this:

Widget build(BuildContext context) {
    return BlocBuilder(
      builder: (context, state) {
        // here you should check about the state that is being provided
        return FutureBuilder(
          future: _future,
          builder: (context, snapshot) {
            //here you should check snapshot.connectionState
            return SizedBox();
          },
        );
      },
    );
}

Answered By – Sebastian

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.