0

In Dart, if:

MyWidget is of type Widget.

Then why:

(BuildContext, ViewModel) => MyWidget

is not a subtype of:

(BuildContext, dynamic) => Widget ?

And how do I fix this?

Marcelo Glasberg
  • 29,013
  • 23
  • 109
  • 133

1 Answers1

1

Because dynamic is a super-type of ViewModel, so a function accepting (BuildContext, ViewModel) as argument can't be used where a function accepting (BuildContext, dynamic) is required. The latter can be called with second arguments that are no ViewModel instances.

So, the problem is in the arguments, not in the return type.

lrn
  • 64,680
  • 7
  • 105
  • 121