text stringlengths 1 372 |
|---|
ListView( |
children: const <widget>[ |
ListTile( |
leading: Icon(Icons.map), |
title: Text('Map'), |
), |
ListTile( |
leading: Icon(Icons.photo_album), |
title: Text('Album'), |
), |
ListTile( |
leading: Icon(Icons.phone), |
title: Text('Phone'), |
), |
], |
), |
<code_end> |
<topic_end> |
<topic_start> |
interactive example |
<code_start> |
import 'package:flutter/material.dart'; |
void main() => runApp(const MyApp()); |
class MyApp extends StatelessWidget { |
const MyApp({super.key}); |
@override |
widget build(BuildContext context) { |
const title = 'basic list'; |
return MaterialApp( |
title: title, |
home: scaffold( |
appBar: AppBar( |
title: const text(title), |
), |
body: ListView( |
children: const <widget>[ |
ListTile( |
leading: Icon(Icons.map), |
title: Text('Map'), |
), |
ListTile( |
leading: Icon(Icons.photo_album), |
title: Text('Album'), |
), |
ListTile( |
leading: Icon(Icons.phone), |
title: Text('Phone'), |
), |
], |
), |
), |
); |
} |
} |
<code_end> |
<topic_end> |
<topic_start> |
create a horizontal list |
you might want to create a list that scrolls |
horizontally rather than vertically. |
the ListView widget supports horizontal lists. |
use the standard ListView constructor, passing in a horizontal |
scrollDirection, which overrides the default vertical direction. |
<code_start> |
ListView( |
// this next line does the trick. |
scrollDirection: axis.horizontal, |
children: <widget>[ |
container( |
width: 160, |
color: colors.red, |
), |
container( |
width: 160, |
color: colors.blue, |
), |
container( |
width: 160, |
color: colors.green, |
), |
container( |
width: 160, |
color: colors.yellow, |
), |
container( |
width: 160, |
color: colors.orange, |
), |
], |
), |
<code_end> |
<topic_end> |
<topic_start> |
interactive example |
desktop and web only: |
this example works in the browser and on the desktop. |
however, as this list scrolls on the horizontal axis |
(left to right or right to left), |
hold shift while using the mouse scroll wheel to scroll the list. |
to learn more, read the breaking change page on the |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.