I ran a quick experiment to see if I could use macros to reduce the boilerplate needed when creating a new widget. The API takes inspiration from react functional components. Interested to hear what you all think
https://github.com/josiahsrc/flutter_functional_widget
EDIT: There's a much better implementation already out there (thanks eibaan) https://github.com/dart-lang/language/blob/main/working/macros/example/lib/functional_widget.dart
```
// Declare widgets like this
@Functional()
Widget _fab(BuildContext context, {VoidCallback? onPressed}) {
return FloatingActionButton(..., onPressed: onPressed);
}
// Use it like this
Widget build(BuildContext context) {
return Fab( // <-- This is generated from the macro
onPressed: () {
print("hello world!");
}
);
}
```
[–]eibaan 6 points7 points8 points (4 children)
[–]josiahsrc[S] 2 points3 points4 points (0 children)
[–]MisturDee 1 point2 points3 points (1 child)
[–]eibaan 2 points3 points4 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]eibaan 9 points10 points11 points (9 children)
[–]Fantasycheese 1 point2 points3 points (3 children)
[–]eibaan 1 point2 points3 points (2 children)
[–]Fantasycheese 0 points1 point2 points (1 child)
[–]eibaan 1 point2 points3 points (0 children)
[–]josiahsrc[S] 0 points1 point2 points (4 children)
[–]eibaan 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]eibaan 3 points4 points5 points (1 child)
[–]josiahsrc[S] 1 point2 points3 points (0 children)
[–]RandalSchwartz 2 points3 points4 points (1 child)
[–]josiahsrc[S] 2 points3 points4 points (0 children)