I'm trying to run an animated splash screen, My issue is I can't figure out if they method I am using is a safe one
Main.dart file
below
//////////////
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Take Note',
theme: ThemeData(
primarySwatch: Colors.green,
),
home: const SplashScreen(),
routes: {
//
// Routes for the app
createOrUpdateNoteRoute: (context) => const CreateUpdateNoteView(),
},
),
);
}
In my splash_screen.dart file I have created a method
void _playVideo() async {
_controller.play();
await Future.delayed(const Duration(seconds: 4));
if (!mounted) {
return;
}
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => BlocProvider<AuthBloc>(
create: (context) => AuthBloc(FirebaseAuthProvider()),
child: const HomePage(),
),
),
);
}
So the code works however I am wondering how to implement this with my AuthBloc + State + Events structure, feel like Navifator/Material Page Route isn't the optimal/safe way to do so.