text
stringlengths
1
474
<topic_end>
<topic_start>
ListView
ListView, a column-like widget, automatically
provides scrolling when its content is too long for
its render box.<topic_end>
<topic_start>Summary (ListView)
<topic_end>
<topic_start>Examples (ListView)
Uses ListView to display a list of businesses using
ListTiles. A Divider separates the theaters from
the restaurants.App source: grid_and_listUses ListView to display the Colors from
the Material 2 Design palette
for a particular color family.Dart code:
colors_demo.dart
<code_start>Widget _buildList() {
return ListView(
children: [
_tile('CineArts at the Empire', '85 W Portal Ave', Icons.theaters),
_tile('The Castro Theater', '429 Castro St', Icons.theaters),
_tile('Alamo Drafthouse Cinema', '2550 Mission St', Icons.theaters),
_tile('Roxie Theater', '3117 16th St', Icons.theaters),
_tile('United Artists Stonestown Twin', '501 Buckingham Way',
Icons.theaters),
_tile('AMC Metreon 16', '135 4th St #3000', Icons.theaters),
const Divider(),
_tile('K\'s Kitchen', '757 Monterey Blvd', Icons.restaurant),
_tile('Emmy\'s Restaurant', '1923 Ocean Ave', Icons.restaurant),
_tile('Chaiya Thai Restaurant', '272 Claremont Blvd', Icons.restaurant),
_tile('La Ciccia', '291 30th St', Icons.restaurant),
],
);
}
ListTile _tile(String title, String subtitle, IconData icon) {
return ListTile(
title: Text(title,
style: const TextStyle(
fontWeight: FontWeight.w500,
fontSize: 20,
)),
subtitle: Text(subtitle),
leading: Icon(
icon,
color: Colors.blue[500],
),
);
}<code_end>
<topic_end>
<topic_start>
Stack
Use Stack to arrange widgets on top of a base
widget—often an image. The widgets can completely
or partially overlap the base widget.<topic_end>
<topic_start>Summary (Stack)
<topic_end>
<topic_start>Examples (Stack)
Uses Stack to overlay a Container
(that displays its Text on a translucent
black background) on top of a CircleAvatar.
The Stack offsets the text using the alignment property and
Alignments.App source: card_and_stackUses Stack to overlay an icon on top of an image.Dart code:
bottom_navigation_demo.dart
<code_start>Widget _buildStack() {
return Stack(
alignment: const Alignment(0.6, 0.6),
children: [
const CircleAvatar(
backgroundImage: AssetImage('images/pic.jpg'),
radius: 100,
),
Container(
decoration: const BoxDecoration(
color: Colors.black45,
),
child: const Text(
'Mia B',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
],
);
}<code_end>
<topic_end>
<topic_start>
Card
A Card, from the Material library,
contains related nuggets of information and can
be composed from almost any widget, but is often used with
ListTile. Card has a single child,
but its child can be a column, row, list, grid,
or other widget that supports multiple children.
By default, a Card shrinks its size to 0 by 0 pixels.
You can use SizedBox to constrain the size of a card.In Flutter, a Card features slightly rounded corners
and a drop shadow, giving it a 3D effect.
Changing a Card’s elevation property allows you to control
the drop shadow effect. Setting the elevation to 24,