Flutter ProxyProvider create failing


When trying to use ProxyProvider
using the example syntax given in https://pub.dev/packages/provider

Widget build(BuildContext context) {
  return MultiProvider(
    providers: [
      ChangeNotifierProvider(create: (_) => Counter()),
      ProxyProvider<Counter, Translations>(
        create: (_, counter, __) => Translations(counter.value),
    child: Foo(),

class Translations {
  const Translations(this._value);

  final int _value;

  String get title => 'You clicked $_value times';

I end up having following error in create function every time:

The argument type ‘Translation Function(BuildContext, dynamic,
dynamic)’ can’t be assigned to the parameter type ‘Translation

what I am doing wrong?


The documentation haven’t updated yet.
In v3.2.0 you should use create with one argument – BuildContext.
You can downgrade to 3.1.0 and continue using builder with 3 arguments.


builder: (context, x, y) => ...


create: (context) => ...

Answered By – Anton Matrenin

Answer Checked By – Jay B. (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.