Layout widgets are used to control how other widgets appear visually. Single-child layout widgets can affect one child widget while multi-child layout widgets can affect many.
A Center widget can take a child widget and have it appear centered in the available space.
Center (child: Text('Hello, world!'))
An Align widget is a more flexible version of the Center widget. Its alignment property can be used to align its child widget in multiple ways.
Align(alignment: Alignment.topRight,child: Text(""In the top right""))
A Row widget is a multi-child layout widget designed to organize content in a horizontal row.
Row(children: const [Text('Left'),Text('Right!')])
Flutter apps are defined by combinations of widgets, the core piece of content in an application. Widgets are created by calling their constructor with parameters defining the widget content.
The base of a Flutter app typically has a main
function with a call to runApp
inside of it. The primary widget of the application, the root widget, is usually a MaterialApp
with a Scaffold
inside of it.
void main {runApp(const MaterialApp(home: Scaffold()));}
A Text widget displays text in an application, with the text to be displayed passed into the widget’s constructor.
Text('Hello, world!')
An Icon widget displays an image from a list of Google provided options.
const myIcon = Icon(Icons.check,color: Colors.green,size: 100.0,);
Flutter is a framework that allows for the creation of applications on many platforms such as:
Flutter has many benefits such as:
Container widgets paint a container box around a child widget. They have properties for specifying how the container box looks: what borders it has, what color it is, and how much spacing.
Container(child: const Icon(Icons.image, size: 50))
The decorator
parameter of the Container widget is able to control the border and colors of the child
widget.
Container(decoration: myDecoration,child: const Icon(Icons.image, size: 50))
Margins are used to specify the amount of empty space around a Container.
Container(margin: const EdgeInsets.all(50))
Padding is used to specify the amount of empty space around the child widgets within a Container.
Container(child: Text('Hello There')padding: const EdgeInsets.all(50))
Transformations are used to visually transform a Container and its child widget(s), adding effects like rotation or skewing.
Container(child: const Text('Hello World'),transform: Matrix4.skewX(0.3))