Using the CircularProgressIndicator

In those screenshots you see what the app looks like when everything has finished loading, but we also need to think about what it looks like while it’s still in the process of loading: we currently display a Divider when it’s loading each tile, but that isn’t really visually pleasing if the user is on a slow network and will therefore look at many dividers stacked on top of each other for a few seconds.

There is a class specifically meant to be used for this placeholder task: the CircularProgressIndicator.[40] It’s not the only progress indicator: there is also a LinearProgressIndicator, but it’s less common and less flexible.

You can just place its constructor (CircularProgressIndicator) anywhere you want to display it (for example, instead of the Divider placeholder for the ComicTile), but that would make it stretch to fill the space given to it. This is fixed by restraining it to a Container with a limited width.

The builder for the FutureBuilder inside the ListView.builder in the HomeScreen becomes the following:

 builder: (context, snapshot) {
 return​ snapshot.hasData ?
  ComicTile(comic: snapshot.data) :
  Container(
  width: 30,
  child: CircularProgressIndicator()
  );
 },
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset