create custom stateful widget flutter code example
Example 1: flutter stateful widget
class YellowBird extends StatefulWidget {
const YellowBird({ Key key }) : super(key: key);
@override
_YellowBirdState createState() => _YellowBirdState();
}
class _YellowBirdState extends State {
@override
Widget build(BuildContext context) {
return Container(color: const Color(0xFFFFE306));
}
}
Example 2: flutter inhereted widget
class MyInherited extends InheritedWidget {
const MyInherited({
Key key,
@required Widget child,
}) : super(key: key, child: child);
static MyInherited of(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType();
}
//if you have properties, it should look something like:
// bool updateShouldNotify(MyInherited old) => old.prop !== new.prop;
//if you don't:
@override
bool updateShouldNotify(MyInherited old) => false;
}