Articles → FLUTTER AND DART → Container widgets in flutter

Container widgets in flutter






Purpose





When container does not have any child element




Picture showing the container widget without the child element in flutter

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"), )));
  }
}


Picture showing the container widget with the child element in flutter

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Friday, August 23, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250