Articles → FLUTTER AND DART → Container Widgets In Flutter
Container Widgets In Flutter
Purpose
When Container Does Not Have Any Child Element
Click to Enlarge
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(), body: Container(
color: Colors.green, child: Text("Test"), )));
}
}
When Container Have Child Element
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(), body: Container(
color: Colors.green, child: Text("Test"), )));
}
}
Click to Enlarge