text
stringlengths
1
474
for example, visually lifts the Card further from the
surface and causes the shadow to become more dispersed.
For a list of supported elevation values, see Elevation in the
Material guidelines.
Specifying an unsupported value disables the drop shadow entirely.<topic_end>
<topic_start>Summary (Card)
<topic_end>
<topic_start>Examples (Card)
A Card containing 3 ListTiles and sized by wrapping
it with a SizedBox. A Divider separates the first
and second ListTiles.App source: card_and_stackA Card containing an image and text.Dart code:
cards_demo.dart
<code_start>Widget _buildCard() {
return SizedBox(
height: 210,
child: Card(
child: Column(
children: [
ListTile(
title: const Text(
'1625 Main Street',
style: TextStyle(fontWeight: FontWeight.w500),
),
subtitle: const Text('My City, CA 99984'),
leading: Icon(
Icons.restaurant_menu,
color: Colors.blue[500],
),
),
const Divider(),
ListTile(
title: const Text(
'(408) 555-1212',
style: TextStyle(fontWeight: FontWeight.w500),
),
leading: Icon(
Icons.contact_phone,
color: Colors.blue[500],
),
),
ListTile(
title: const Text('costa@example.com'),
leading: Icon(
Icons.contact_mail,
color: Colors.blue[500],
),
),
],
),
),
);
}<code_end>
<topic_end>
<topic_start>
ListTile
Use ListTile, a specialized row widget from the
Material library, for an easy way to create a row
containing up to 3 lines of text and optional leading
and trailing icons. ListTile is most commonly used in
Card or ListView, but can be used elsewhere.<topic_end>
<topic_start>Summary (ListTile)
<topic_end>
<topic_start>Examples (ListTile)
A Card containing 3 ListTiles.App source: card_and_stackUses ListTile with leading widgets.Dart code:
list_demo.dart<topic_end>
<topic_start>
Constraints
To fully understand Flutter’s layout system, you need
to learn how Flutter positions and sizes
the components in a layout. For more information,
see Understanding constraints.<topic_end>
<topic_start>
Videos
The following videos, part of the
Flutter in Focus series,
explain Stateless and Stateful widgets.Flutter in Focus playlistEach episode of the
Widget of the Week series
focuses on a widget. Several of them includes layout widgets.Flutter Widget of the Week playlist<topic_end>
<topic_start>
Other resources
The following resources might help when writing layout code.
<topic_end>
<topic_start>Build a Flutter layout
<topic_end>
<topic_start>
What you’ll learn
This tutorial explains how to design and build layouts in Flutter.If you use the example code provided, you can build the following app.Photo by Dino Reichmuth on Unsplash.
Text by Switzerland Tourism.To get a better overview of the layout mechanism, start with
Flutter’s approach to layout.<topic_end>
<topic_start>
Diagram the layout
In this section, consider what type of user experience you want for
your app users.Consider how to position the components of your user interface.
A layout consists of the total end result of these positionings.
Consider planning your layout to speed up your coding.
Using visual cues to know where something goes on screen can be a great help.Use whichever method you prefer, like an interface design tool or a pencil
and a sheet of paper. Figure out where you want to place elements on your
screen before writing code. It’s the programming version of the adage:
“Measure twice, cut once.”Ask these questions to break the layout down to its basic elements.Identify the larger elements. In this example, you arrange the image, title,
buttons, and description into a column.Diagram each row.Row 1, the Title section, has three children: