container widget flutter code example
Example 1: flutter container
Center(
child: Container(
margin: const EdgeInsets.all(10.0),
color: Colors.amber[600],
width: 48.0,
height: 48.0,
),
)
Example 2: 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));
}
}
Example 3: flutter container
Center(
child: Container(
margin: const EdgeInsets.all(10.0),
color: Colors.amber[600],
width: 48.0,
height: 48.0,
),
)
Example 4: 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<MyInherited>();
}
@override
bool updateShouldNotify(MyInherited old) => false;
}