Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter how to make skeleton loader

Tags:

flutter

dart

I have this card product card, get it from api with FutureBuilder, when my card is loading i want to show skeleton loader not just CircularProgressIndicator , how can i make it.

My futureBuilder:

FutureBuilder<List<Product>>(
               future: productFuture,
               builder: (context, snapshot) {
                 if (snapshot.connectionState == ConnectionState.waiting) {
                   return Center(child: CircularProgressIndicator());
                 } else if (snapshot.hasData) {
                   final catalog = snapshot.data;
                   return buildCatalog(catalog!);
                 } else {
                   return Text("No widget to build");
                 }
               }),

here is example of skeleton loader

like image 564
st4tic Avatar asked Jul 20 '26 09:07

st4tic


1 Answers

You can try this package : shimmer

   Shimmer.fromColors(
      baseColor: Colors.red,
      highlightColor: Colors.yellow,
      child: Container(
        height: 20,
        width: 100,
        color: Colors.white,
      ),
    );
like image 118
manhtuan21 Avatar answered Jul 23 '26 00:07

manhtuan21