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/intro/presentation/bloc/intro_event.dart';
|
|
import 'package:hadi_hoda_flutter/features/intro/presentation/bloc/intro_state.dart';
|
|
|
|
class IntroBloc extends Bloc<IntroEvent, IntroState> {
|
|
/// ------------constructor------------
|
|
IntroBloc() : super(const IntroState());
|
|
|
|
/// ------------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------------
|
|
}
|