簡體   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

這是我的主要 .dart,錯誤就在此圖像中,這是我在屏幕上遇到的錯誤。 我正在嘗試解決但它不在我手中解決,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(),
      },
    )
  );
}

這是引發特定錯誤的無狀態小部件,我不知道它在哪里引發。

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

我在我的android屏幕上遇到了這個錯誤。

嘗試在 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM