[英]I am trying to navigate home screen via Start screen through main.dart but failed to navigate. I am new to flutter and can't understand this error. Pl
This is my main .dart and the error is here that is In This Image this is the error that I got on the screen.这是我的主要 .dart,错误就在此图像中,这是我在屏幕上遇到的错误。 I am trying to solve but it is not in my hand to solve, Swipe Bloc throws an error, I tried too much to solve it but every time I see failure to solve it.
我正在尝试解决但它不在我手中解决,Swipe Bloc 抛出一个错误,我尝试了太多来解决它,但每次我看到无法解决它。
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
// runApp(MyApp());
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: MyLogin(),
routes: {
'register': (context) => MyRegister(),
'login': (context) => MyLogin(),
},
)
);
}
Here is the stateless widget which throws the particular error which I don't know where it throws.这是引发特定错误的无状态小部件,我不知道它在哪里引发。
class MyHome extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MultiRepositoryProvider(
providers: [
RepositoryProvider(
create: (context) => AuthRepository(),
),
RepositoryProvider(
create: (context) => StorageRepository(),
),
RepositoryProvider(
create: (context) => DatabaseRepository(),
),
],
child: MultiBlocProvider(
providers: [
BlocProvider(
create: (context) => AuthBloc(
authRepository: context.read<AuthRepository>(),
),
),
// BlocProvider(
// create: (context) => SwipeBloc()
// ..add(
// LoadUsers(users: User.users.where((user) => user.id != 1).toList(),
// ),
// ),
// ),
BlocProvider<SignupCubit>(
create: (context) =>
SignupCubit(authRepository: context.read<AuthRepository>()),
),
BlocProvider<OnboardingBloc>(
create: (context) => OnboardingBloc(
databaseRepository: context.read<DatabaseRepository>(),
storageRepository: context.read<StorageRepository>(),
),
),
BlocProvider(
create: (context) => ProfileBloc(
authBloc: context.read<AuthBloc>(),
databaseRepository: context.read<DatabaseRepository>(),
)..add(
LoadProfile(userId: context.read<AuthBloc>().state.user!.uid),
),
),
],
child: MultiBlocProvider(
providers: [
BlocProvider(
create: (context) => SwipeBloc()
..add(
LoadUsers(users: User.users.where((user) => user.id != 1).toList(),
),
),
),
],
child:
MaterialApp(
),
),
),
);
}
}
Try to initialize all your providers above MaterialApp, like in this code尝试在 MaterialApp 之上初始化所有提供程序,就像在这段代码中一样
void main() {
runApp(
MultiRepositoryProvider(
providers: [
RepositoryProvider(
create: (context) => AuthRepository(),
),
RepositoryProvider(
create: (context) => StorageRepository(),
),
RepositoryProvider(
create: (context) => DatabaseRepository(),
),
],
child: MultiBlocProvider(
providers: [
BlocProvider(
create: (context) => AuthBloc(
authRepository: context.read<AuthRepository>(),
),
),
],
child: MaterialApp(),
),
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.