0
Q:

how to make reusable widget in flutter

Widget buildListContainer(Widget list) {
    return Container(
      height: 300,
      child: ,
    );
  }
1
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