import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:medcify/network/api_provider.dart'; import 'package:medcify/storage/storage.dart'; import '../../../models/banner_item.dart'; abstract class HomeState{} class HomeInitial extends HomeState{} class HomeLoading extends HomeState{} class HomeSuccess extends HomeState{} class HomeCubit extends Cubit { HomeCubit() : super(HomeInitial()); List banners = []; dynamic ordersCount = 0; dynamic salesCount = 0; dynamic visitorsCount = 0; String url = ""; String storeName = ""; int notificationCount = 0; Future fetchHomeData() async{ emit(HomeLoading()); final response = await ApiProvider.instance.fetchHomeData(); banners = response[0].banners; ordersCount = response[1].count; salesCount = response[2].count; visitorsCount = response[3].count; notificationCount = response[5].count; url = response[4].url; storeName = response[4].name; if(url.isNotEmpty)Storage.instance.setStoreUrl(url); emit(HomeSuccess()); } }