エラー内容
1 | The argument type 'Widget Function(BuildContext, Widget, dynamic)' can't be assigned to the parameter type 'Widget Function(BuildContext, Widget)'. |
ChangeNotifierProxyProvider
のbuilderに適切な情報を入れているはずなのにエラーが消えなかったので調べてみたところ、4系からはbuilder
ではなくupdate
を使うらしいです。
1 2 3 4 5 6 7 8 9 | // ダメ ChangeNotifierProxyProvider<Auth, Products>( builder: (ctx, auth, previousProducts) => Products(auth.token, previousProducts == null ? [] : previousProducts.items), ), // OK ChangeNotifierProxyProvider<Auth, Products>( update: (ctx, auth, previousProducts) => Products(auth.token, previousProducts == null ? [] : previousProducts.items), ), |
参考記事
なし