首页 > 解决方案 > bulderFunctions 的 openContainer 之上的提供者

问题描述

ChangeNotifierProvider(
              create: (context) => BuyValuableNotifier(),
              child: OpenContainer(
              
                closedBuilder: (context, action) {
                  return Container();
                },
                openBuilder: (context, action) {
                  return SingleWidget();
                },
              ),
            ),

所以调用 openBuilder 时出现此错误:错误:在此 SingleWidget 小部件上方找不到正确的提供程序

OpenContainer(
              closedBuilder: (context, action) {
                return Container();
              },
              openBuilder: (context, action) {
                return ChangeNotifierProvider(
                    create: (context) => BuyValuableNotifier(),
                    child: SingleWidget();
              },
            ),

如果我这样做,我会在 openBuilder 关闭时丢失数据我该怎么办?

标签: flutterdartanimationproviderchangenotifier

解决方案


推荐阅读