You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							44 lines
						
					
					
						
							1.3 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							44 lines
						
					
					
						
							1.3 KiB
						
					
					
				
								import 'package:bloc/bloc.dart';
							 | 
						|
								import 'package:flutter/cupertino.dart';
							 | 
						|
								import 'package:go_router/go_router.dart';
							 | 
						|
								import 'package:hadi_hoda_flutter/common_ui/resources/my_assets.dart';
							 | 
						|
								import 'package:hadi_hoda_flutter/core/routers/my_routes.dart';
							 | 
						|
								import 'package:hadi_hoda_flutter/features/splash/presentation/bloc/splash_event.dart';
							 | 
						|
								import 'package:hadi_hoda_flutter/features/splash/presentation/bloc/splash_state.dart';
							 | 
						|
								
							 | 
						|
								class SplashBloc extends Bloc<SplashEvent, SplashState> {
							 | 
						|
								  /// ------------constructor------------
							 | 
						|
								  SplashBloc() : super(const SplashState());
							 | 
						|
								
							 | 
						|
								  /// ------------UseCases------------
							 | 
						|
								
							 | 
						|
								  /// ------------Variables------------
							 | 
						|
								
							 | 
						|
								  /// ------------Controllers------------
							 | 
						|
								
							 | 
						|
								  /// ------------Functions------------
							 | 
						|
								  Future<void> _precacheAllImages(BuildContext context) async {
							 | 
						|
								    await Future.wait(
							 | 
						|
								      MyAssets.images.map(
							 | 
						|
								        (assetPath) => precacheImage(AssetImage(assetPath), context),
							 | 
						|
								      ),
							 | 
						|
								    );
							 | 
						|
								  }
							 | 
						|
								
							 | 
						|
								  Future<void> goToHomePage(BuildContext context) async {
							 | 
						|
								    if (context.mounted) {
							 | 
						|
								      await _precacheAllImages(context);
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    await Future.delayed(
							 | 
						|
								      Duration(seconds: 2),
							 | 
						|
								      () {
							 | 
						|
								        if (context.mounted) {
							 | 
						|
								          context.goNamed(Routes.homePage);
							 | 
						|
								        }
							 | 
						|
								      },
							 | 
						|
								    );
							 | 
						|
								  }
							 | 
						|
								
							 | 
						|
								  /// ------------Api Calls------------
							 | 
						|
								}
							 |