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