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?
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?
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.