I have a generic static method that looks like this:
static build<K>() {
return (GenericClass<K> param) => MyClass<K>(param);
}
So far I have tried:
typedef F = MyClass<K> Function(GenericClass<K> param);
but it says that:
The return type '(GenericClass<K>) → MyClass<K>' isn't a '(GenericClass<dynamic>) → MyClass<dynamic>', as defined by the method 'build'.
and
typedef F = SimpleViewModel<K> Function<k>(Store<K> param);
Which says that:
The return type '(GenericClass<K>) → MyClass<K>' isn't a '<K>(GenericClass<K>) → MyClass<K>', as defined by the method 'build'.
MyClass
looks like this:
class MyClass<T> {
final GenericClass<T> param;
MyClass(this.param);
static build<K>() {
return (GenericClass<K> param) => MyClass<K>(param);
}
}
So, what is a valid typedef
for it?
typedef F<I> = MyClass<I> Function(GenericClass<I> param);
andstatic F<K> build<K>() {...}
, makes sense to me, but I can't still explain why, though. – Captious