The point of this question, is how to handle state changes, preferably automatically by the original ancestor. It seems to me that it is not possible to keep extending these
Don't. You should never extend a widget. This is anti-pattern. Instead, as stated by flutter documentation :
You create a layout by composing widgets to build more complex widgets.
An example would be :
class Foo extends StatefulWidget {
final Widget child;
Foo({this.child});
@override
_FooState createState() => new _FooState();
}
class _FooState extends State {
@override
Widget build(BuildContext context) {
return new Container(
child: widget.child
);
}
}
class Bar extends StatefulWidget {
final Widget child;
Bar({this.child});
@override
_BarState createState() => new _BarState();
}
class _BarState extends State {
@override
Widget build(BuildContext context) {
return new Foo(
child: widget.child
);
}
}
In this case, Bar
has no mixin or inheritance. It just wrap it's child inside a Foo
.