Please help
This is my MyApp Class
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Instagram',
theme: ThemeData(
primarySwatch: Colors.blue,
inputDecorationTheme: InputDecorationTheme(
enabledBorder: OutlineInputBorder(
borderSide:
BorderSide(width: 1, color: Colors.white.withOpacity(0.2)),
),
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(width: 1, color: Colors.white.withOpacity(0.2)),
),
),
),
// here I am providing the cubit to my SplashCubit Class
home: BlocProvider(
create: (context) => SplashCubit()..checkSavedDetails(),
child: const SplashScreen()),
);}}
this is my SplashScreen
class
class SplashScreen extends StatelessWidget {
const SplashScreen({super.key});
@override
Widget build(BuildContext context) {
return BlocBuilder<SplashCubit,SplashState>(
builder: (context, state) {
return AnimatedSplashScreen(
duration: 3000,
centered: true,
splash: Image.asset('assets/images/instagram_logo.jpg'),
backgroundColor: Colors.black,
nextScreen: state.dataSaved
? HomePage()
: LoginPage(),
});}}
please help, Not able to figure out what is getting wrong
I checked everything but it is giving the below error.
2
Answers
You need to setup up MultiBlocProvider with all the Providers for your Cubits first and then make MaterialApp (and SplashScreen) a child of MultiBlocProvider. It should look something like this:
If you are using SplashBloc only for Splash Screen.Then you can try this