Flutter ChangeNotifierProvider的参数“更新”是必需的

时间:2019-12-19 15:28:23

标签: flutter dart

有了我的最新更新:

  

警告:参数'update'是必需的。 。 (missing_required_pa​​ram   在[pos_mobile] lib \ main.dart)

 return MultiProvider(
        providers: [
          ChangeNotifierProvider.value(
            value: Auth(),
          ),
          ChangeNotifierProxyProvider<Auth, Operatori>( // here I got the warning
            builder: (ctx, auth, prevData) => Operatori(auth.token, auth.userId,
                prevData == null ? [] : prevData.operatori),
          ),

谢谢

1 个答案:

答案 0 :(得分:2)

检查ChangeNotifierProxyProvider doc

应该是:

ChangeNotifierProxyProvider<Foo, MyChangeNotifier>(
  create: (_) => MyChangeNotifier(),
  update: (_, foo, myNotifier) => myNotifier
    ..foo = foo,
  child: ...
);