Closed
Description
In the original issue for introducing typedefs for non-function types, I saw questions about how extensions would work with this new feature. However, it seems that this did not make the cut yet.
The purpose of this could be something like this to parse more conveniently json lists of objects:
typedef Cars= List<Car>;
extension on Cars{
Cars fromJson(List json) {
final Cars cars = [];
for (final car in json) {
cars.add(Car.fromJson(car as Map<String, dynamic>));
}
return cars;
}
}
Original comment:
That's how it works already with extensions on functions, so likely.
typedef VoidCallback = void Function();
extension on VoidCallback {
void foo() {}
}
void main() {
void Function() test = () {};
test.foo();
}
Originally posted by @rrousselGit in #65 (comment)
Metadata
Metadata
Assignees
Labels
No labels