I've read in couple places that extending a Flutter widget is an anti-pattern. Is that true?
I've used widget subclassing to cut down on nesting by subclassing the widget I'm removing and put its widgets in its constructor, like so
class Foo extends FormBuilder {
Foo() : super (
// bunch of widgets here
);
}
Extending a stateless widget seems more popular, but it adds a few more lines of code and a widget to the tree, which isn't my preference:
class Foo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FormBuilder(
// bunch of widgets here
);
}
I've read returning a widget from a function is an antipattern because it breaks rendering optimization. Does my first approach likewise have hidden side effects? I.e., is it really an antipattern?