gpt4 book ai didi

android - 与flutter中更改通知提供程序相关的问题

转载 作者:行者123 更新时间:2023-12-04 14:53:53 24 4
gpt4 key购买 nike

使用 changenotifierprovider 时出现错误在我的 flutter 项目中。
错误:
“MyUser”不符合绑定(bind)的“ChangeNotifier?”类型参数“T”。
尝试使用“ChangeNotifier?”的子类或子类的类型。

类(class):

class SettingsForm extends StatefulWidget {
static Widget getWidget() {
return new Provider(
create: (_) => MyUser(uid: ''),
child: ChangeNotifierProvider( <-- here **ChangeNotifierProvider**
create: (BuildContext context) => MyUser(uid: ''),
builder: (_, _) => SettingsForm()),
)
);
}

最佳答案

只需添加 with ChangeNotifierMyUser类(class)。

class MyUser with ChangeNotifier {}

关于android - 与flutter中更改通知提供程序相关的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68519539/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com