如何修复导航器不使用颤音集蓝色模式工作的导航器?

发布于 2025-01-25 09:17:35 字数 328 浏览 2 评论 0原文

我正在尝试使用Pokemon API作为练习来制作应用程序。 我正在尝试使用集体模式进行。 如果您单击网格,则需要获得索引并移至细节页面。 获得索引可以很好,但不会访问页面。 我似乎无法构建页面,但我不知道问题是什么。 如果您能告诉我问题是什么,这将不胜感激。

我将代码放在github上,因为很高兴看到整个代码。

https://github.com/jun-kor/pokedex.gitex.git

I am trying to make an application using Pokemon api as an exercise.
I am trying to make it using the Bloc pattern.
If you click on GridTile, you need to get indexID and move to DetailPage.
Getting the IndexID is fine, but it doesn't go to the page.
I can't seem to build the page, but I don't know what the problem is.
It would be really appreciated if you could tell me what the problem is.

I put the code on github because it would be good to see the whole code.

https://github.com/Jun-Kor/pokedex.git

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

望笑 2025-02-01 09:17:35

主要问题不是您的导航,而是您的群众,发生的事情是,当您输入 Pokemondetailsview 页面时,使用 blocbuilder< pokemondetailsbloc,pokemondetailsstate> 它找不到其提供者。 (主要是一个)但是,如果我们直接去那里,您就写了它,对吗?

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.red,
      ),
      home: MultiBlocProvider( // here is the problem
        providers: [
          BlocProvider<PokemonBloc>(
              create: (context) =>
                  PokemonBloc()..add(const PokemonPageRequestEvent(page: 0))),
          BlocProvider<PokemonDetailsBloc>(
              create: (context) => PokemonDetailsBloc()),
        ],
        child: const PokedexView(),
      ),
    );
  }
}

好吧, Multiblocprovider 必须是为整个 MitalialApp 提供的主要父母,而不是它的孩子,我的意思是?这就是为什么问题是要一个集团提供商,但是我
它找不到一个。

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MultiBlocProvider(  // change here
      providers: [
        BlocProvider<PokemonBloc>(
            create: (context) =>
                PokemonBloc()..add(const PokemonPageRequestEvent(page: 0))),
        BlocProvider<PokemonDetailsBloc>(
            create: (context) => PokemonDetailsBloc()),
      ],
      child: MaterialApp(
        title: 'Material App',
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
          primarySwatch: Colors.red,
        ),
        home: const PokedexView(),
      ),
    );
  }
}

The main problem is not your navigation, it's your Bloc, what happens is that when you enter the PokemonDetailsView page, with the BlocBuilder<PokemonDetailsBloc, PokemonDetailsState> it cannot find its provider (the one in the main) but, if we go directly there, you have it written, right ?

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.red,
      ),
      home: MultiBlocProvider( // here is the problem
        providers: [
          BlocProvider<PokemonBloc>(
              create: (context) =>
                  PokemonBloc()..add(const PokemonPageRequestEvent(page: 0))),
          BlocProvider<PokemonDetailsBloc>(
              create: (context) => PokemonDetailsBloc()),
        ],
        child: const PokedexView(),
      ),
    );
  }
}

Well, the MultiBlocProvider has to be the main parent that is going to provide for the whole MaterialApp, not be a child of it, I mean ? That's why the problem was asking for a Bloc provider, but I
it couldn't find one.

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MultiBlocProvider(  // change here
      providers: [
        BlocProvider<PokemonBloc>(
            create: (context) =>
                PokemonBloc()..add(const PokemonPageRequestEvent(page: 0))),
        BlocProvider<PokemonDetailsBloc>(
            create: (context) => PokemonDetailsBloc()),
      ],
      child: MaterialApp(
        title: 'Material App',
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
          primarySwatch: Colors.red,
        ),
        home: const PokedexView(),
      ),
    );
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文