text
stringlengths
1
372
global keys
use global keys to uniquely identify child widgets.
global keys must be globally unique across the entire
widget hierarchy, unlike local keys which need
only be unique among siblings. because they are
globally unique, a global key can be used to
retrieve the state associated with a widget.
for more information, check out the GlobalKey API.
<topic_end>
<topic_start>
widget catalog
create beautiful apps faster with flutter’s collection of visual, structural,
platform, and interactive widgets. in addition to browsing widgets by category,
you can also see all the widgets in the widget index.
make your app accessible.
bring animations to your app.
manage assets, display images, and show icons.
async patterns to your flutter application.
widgets you absolutely need to know before building your first flutter app.
beautiful and high-fidelity widgets for current iOS design language.
take user input in addition to input widgets in material components and cupertino.
respond to touch events and route users to different views.
arrange other widgets columns, rows, grids, and many other layouts.
widgets implementing the material 2 design guidelines.
visual, behavioral, and motion-rich widgets implementing the material 3 design specification.Material 3 is the default flutter interface as of flutter 3.16. to learn more about this transition, check out flutter support for material 3.
these widgets apply visual effects to the children without changing their layout, size, or position.
scroll multiple widgets as children of the parent.
manage the theme of your app, makes your app responsive to screen sizes, or add padding.
display and style text.
<topic_end>
<topic_start>
widget of the week
100+ short, 1-minute explainer videos to
help you quickly get started with flutter widgets.
see more widget of the weeks
<topic_end>
<topic_start>
layouts in flutter
<topic_end>
<topic_start>
what's the point?
the core of flutter’s layout mechanism is widgets.
in flutter, almost everything is a widget—even
layout models are widgets. the images, icons,
and text that you see in a flutter app are all widgets.
but things you don’t see are also widgets,
such as the rows, columns, and grids that arrange,
constrain, and align the visible widgets.
you create a layout by composing widgets to build more complex widgets.
for example, the first screenshot below shows 3 icons with a label
under each one:
the second screenshot displays the visual layout, showing a row of
3 columns where each column contains an icon and a label.
info note
most of the screenshots in this tutorial are displayed with
debugPaintSizeEnabled set to true so you can see the visual layout.
for more information, see
debugging layout issues visually, a section in
using the flutter inspector.
here’s a diagram of the widget tree for this UI:
most of this should look as you might expect, but you might be wondering
about the containers (shown in pink). container is a widget class
that allows you to customize its child widget. use a container when
you want to add padding, margins, borders, or background color,
to name some of its capabilities.
in this example, each text widget is placed in a container
to add margins. the entire row is also placed in a
container to add padding around the row.
the rest of the UI in this example is controlled by properties.
set an icon’s color using its color property.
use the text.style property to set the font, its color, weight, and so on.
columns and rows have properties that allow you to specify how their
children are aligned vertically or horizontally, and how much space
the children should occupy.
<topic_end>
<topic_start>
lay out a widget
how do you lay out a single widget in flutter? this section
shows you how to create and display a simple widget.
it also shows the entire code for a simple hello world app.
in flutter, it takes only a few steps to put text, an icon,
or an image on the screen.
<topic_end>
<topic_start>
1. select a layout widget
choose from a variety of layout widgets based
on how you want to align or constrain the visible widget,
as these characteristics are typically passed on to the
contained widget.
this example uses center which centers its content
horizontally and vertically.
<topic_end>
<topic_start>
2. create a visible widget
for example, create a text widget:
<code_start>
Text('Hello world'),
<code_end>
create an image widget:
<code_start>