Reputation: 53
So, I'm really new to flutter or dart. I looked at many tutorials, a bit hard to learn.
I need to know if I can, and how can I add more containers that contain Texts or Button in Flutter.
I already tried many things, but everything gives me an error. I want to put some buttons in one container, and in another container I want to add some labels. and I need to put these two containers at my Scaffold, how I do it?
or maybe how can I add two scaffolds on the same page, so I need labels at one and buttons in other.
import 'package:flutter/material.dart';
void main() => runApp (MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My Tittle',
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar:AppBar(
title: Text('My Title'),
),
body: Container(
child: Text('Hello World),
), //Container
# I WANT TO ADD ANOTHER CONTAINER HERE
), //Scaffold
); //MaterialApp
}
}
Upvotes: 1
Views: 9173
Reputation: 747
There are a few different ways to achieve that. You can use the Column
widget
Column(
children: <Widget>[
Container(),
Container(),
],
)
and the result will be a set of child elements one under another. Another way of doing so is to use the Row
widget
Row(
children: <Widget>[
Container(),
Container(),
],
)
In this case, the result would be a set of elements displayed one next to another.
There are also a few more different ways that you can use to display a list of elements like Stack
and ListView
. Try them and choose the one that meets your requirements
Upvotes: 4