简体   繁体   English

我正在尝试通过 main.dart 通过开始屏幕导航主屏幕,但无法导航。 我是新来的,无法理解这个错误。 PL

[英]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(
          
        ),
        ),
      ),
    );
  }
}

This error I got on my android sceen.我在我的android屏幕上遇到了这个错误。

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.

相关问题 这是我每次尝试运行 flutter 在 main.dart 中提供的代码时遇到的错误 - this is the error I am getting every time I try to run the code that flutter provides in main.dart 我如何将 main.dart 中的变量访问到颤振中的其他页面,我正在使用 Getx 状态管理 - How can i access to a variable in main.dart to other pages in flutter, i am using Getx state management 导航到 Flutter 中的新屏幕 - Navigate to a new screen in Flutter 当我使用根名称导航时,如何在Flutter中创建全屏对话框? - How to create full screen dialog in flutter when I am using root names to Navigate? 我已经实现了连接和提供者 package 但我在 main.dart 中收到以下错误 - I have implemented connectivity and provider package but I am getting the below error in main.dart Flutter:如何使用DropDownMenuItems导航到新屏幕 - Flutter: How do I navigate to a new screen using DropDownMenuItems 如何在同一 lib 文件夹中的其他 screen.dart 文件中使用 main.dart 中的 flutter 变量? - How do i use flutter variables from main.dart in other screen.dart files in the same lib folder? Flutter-导航到新屏幕并返回 - Flutter - Navigate to a new screen and back Flutter 返回 Main.dart 屏幕而不是关闭应用程序 - Flutter returns Main.dart screen instead of closing the Application Flutter:如何在永久底部导航栏中导航到新屏幕 package - Flutter: How can I Navigate to new screen in Persistent Bottom Navigation Bar package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM