custom tab flutter code example

Example: flutter appbar actions with tabs

class MyStatefulWidget extends StatefulWidget{
@override
  MyStatefulWidgetState createState() => MyStatefulWidgetState();

  static MyStatefulWidgetState of(BuildContext context){
    return (context.inheritFromWidgetOfExactType(_MyInheritedStateContainer) as _MyInheritedStateContainer).data;
  }
}
class MyStatefulWidgetState extends State<MyStatefulWidget>{

String variableCalledHello = "Hello World";
@override
  void initState() {
    super.initState();
  }
 @override
  Widget build(BuildContext context) {
   return new _MyInheritedStateContainer(data:this,child:/* Body here */);
  }
}
class _MyInheritedStateContainer extends InheritedWidget{
    _MyInheritedStateContainer({
Key key,
    @required Widget child,
    @required this.data,
  }) : super(key: key, child: child);

final MyStatefulWidgetState data;

 @override
  bool updateShouldNotify(_MyInheritedStateContainer oldWidget) {
    return true;
  }
}

Tags:

Misc Example