エラー内容

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 を使うらしいです。

// ダメ
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),
),

参考記事

なし

コメントをどうぞ

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

CAPTCHA