text stringlengths 1 372 |
|---|
material widgets |
<topic_end> |
<topic_start> |
container |
many layouts make liberal use of containers to separate |
widgets using padding, or to add borders or margins. |
you can change the device’s background by placing the |
entire layout into a container and changing its background |
color or image. |
<topic_end> |
<topic_start> |
summary (container) |
<topic_end> |
<topic_start> |
examples (container) |
this layout consists of a column with two rows, each containing |
2 images. a container is used to change the background color |
of the column to a lighter grey. |
a container is also used to add a rounded border and margins |
to each image: |
<code_start> |
widget _buildDecoratedImage(int imageIndex) => expanded( |
child: container( |
decoration: BoxDecoration( |
border: border.all(width: 10, color: colors.black38), |
borderRadius: const BorderRadius.all(Radius.circular(8)), |
), |
margin: const EdgeInsets.all(4), |
child: Image.asset('images/pic$imageIndex.jpg'), |
), |
); |
widget _buildImageRow(int imageIndex) => row( |
children: [ |
_buildDecoratedImage(imageIndex), |
_buildDecoratedImage(imageIndex + 1), |
], |
); |
<code_end> |
you can find more container examples in the tutorial. |
app source: container |
<topic_end> |
<topic_start> |
GridView |
use GridView to lay widgets out as a two-dimensional |
list. GridView provides two pre-fabricated lists, |
or you can build your own custom grid. when a GridView |
detects that its contents are too long to fit the render box, |
it automatically scrolls. |
<topic_end> |
<topic_start> |
summary (gridview) |
info note |
when displaying a two-dimensional list where it’s important which |
row and column a cell occupies (for example, |
it’s the entry in the “calorie” column for the “avocado” row), use |
table or DataTable. |
<topic_end> |
<topic_start> |
examples (gridview) |
uses GridView.extent to create a grid with tiles a maximum |
150 pixels wide. |
app source: grid_and_list |
uses GridView.count to create a grid that’s 2 tiles |
wide in portrait mode, and 3 tiles wide in landscape mode. |
the titles are created by setting the footer property for |
each GridTile. |
dart code: |
grid_list_demo.dart |
<code_start> |
widget _buildGrid() => GridView.extent( |
maxCrossAxisExtent: 150, |
padding: const EdgeInsets.all(4), |
mainAxisSpacing: 4, |
crossAxisSpacing: 4, |
children: _buildGridTileList(30)); |
// the images are saved with names pic0.jpg, pic1.jpg...pic29.jpg. |
// the list.generate() constructor allows an easy way to create |
// a list when objects have a predictable naming pattern. |
List<Container> _buildGridTileList(int count) => list.generate( |
count, (i) => container(child: image.asset('images/pic$i.jpg'))); |
<code_end> |
<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_list |
uses ListView to display the colors from |
the material 2 design palette |
for a particular color family. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.