Future Builder
unknown
dart
2 years ago
1.8 kB
1
Indexable
Never
FutureBuilder( future: HomeApis().getHomeCategories(), builder: (_, snapshot) { //*WIDGET TO BUILD IF DATA IS DONE LOADING CORRECTLY if (snapshot.hasData) { categoriesList = snapshot.data as List<CategoryItem>; return SizedBox( width: Get.width, height: 100.h, child: ListView.builder( itemCount: categoriesList.length, scrollDirection: Axis.horizontal, padding: EdgeInsets.symmetric(horizontal: 7.w), itemBuilder: (context, index) { return MealCard( title: categoriesList[index].name ?? '', color: AppConstants.colorsMenu[index], image: categoriesList[index].image ?? ''); }, )); } //*OTHERWISE BUILD LOADING WIDGET else { return SizedBox( width: Get.width, height: 100.h, child: ListView.builder( itemCount: categoriesList.length, scrollDirection: Axis.horizontal, padding: EdgeInsets.symmetric(horizontal: 7.w), itemBuilder: (context, index) { return MealLoading(60, 60); }, )); } }),