Esteban
0
Q:

stateless widget flutter

class GreenFrog extends StatelessWidget {
  const GreenFrog({ Key key }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(color: const Color(0xFF2DBD3A));
  }
}
2
class YellowBird extends StatefulWidget {
  const YellowBird({ Key key }) : super(key: key);

  @override
  _YellowBirdState createState() => _YellowBirdState();
}

class _YellowBirdState extends State<YellowBird> {
  @override
  Widget build(BuildContext context) {
    return Container(color: const Color(0xFFFFE306));
  }
}
3
class MyClass extends StatefulWidget {
	@override
    MyClassState createState() => new MyClassState();
}

class MyClassState extends State<MyClass> {
	//Widgets and other code here
}
0
class MyInherited extends InheritedWidget {
  const MyInherited({
    Key key,
    @required Widget child,
  }) : super(key: key, child: child);


  static MyInherited of(BuildContext context) {
    return context.dependOnInheritedWidgetOfExactType<MyInherited>();
  }

  //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;
  
}
0

New to Communities?

Join the community