-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Closed
Description
Steps to Reproduce
Maybe this is more a dart specific issue, but since I found this while developing flutter app so I decided to post it here. I have written a small example try to reproduce the issue.
So basically I want to create a generic class(Test<T, F>) but with some variable(_cellBuilder) has an external typedef type(CellBuilder<F>) outside the class. testA with String assigned runs fine, but testB failed just as the screenshot shows.
And when I remove <Product> from testB, I get a different error.
type '(Product) => Widget is not a subtype of type (dynamic) => Widget
Quite confusing. Any help please?
void main() {
testA<String>(String content) {
print(content);
}
Widget testB<Product>(Product item) {
print(item.a);
}
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
Test<int, Product> c = Test(testA, testB);
c.eval();
});
}
class Product {
final String a;
Product(this.a);
}
typedef CellBuilder<F> = Widget Function(F item);
typedef testString<T>(T text);
class Test<T, F> {
final testString _f;
final CellBuilder _cellBuilder;
Test(testString this._f, CellBuilder this._cellBuilder);
eval() {
_f("hello");
_cellBuilder(Product("world"));
}
}Logs
Metadata
Metadata
Assignees
Labels
No labels
