如何在flutter中添加项目符号或创建项目符号列表 [英] How do I add a bullet or create a bulleted list in flutter
本文介绍了如何在flutter中添加项目符号或创建项目符号列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个列表,我想为每个项目添加一个项目符号(我使用的是new Column
,因为我不想实现滚动).我将如何创建项目符号列表?
I have a list and I want to add a bullet to each item (I'm using new Column
because I don't want to implement scrolling). How would I create a bulleted list?
我在想也许是一个图标,但也许有一种方法可以将装饰类用于文本样式.
推荐答案
下面的小部件将创建一个实心圆形状,因此您可以为列中的每个项目调用此小部件.
Following widget will create a filled circle shape, So you can call this widget for every item in your column.
class MyBullet extends StatelessWidget{
@override
Widget build(BuildContext context) {
return new Container(
decoration: new BoxDecoration(
color: Colors.black,
shape: BoxShape.circle,
),
);
}
}
希望这就是您想要的!
class MyList extends StatelessWidget{
@override
Widget build(BuildContext context) {
return new Column(
children: <Widget>[
new ListTile(
leading: new MyBullet(),
title: new Text('My first line'),
),
new ListTile(
leading: new MyBullet(),
title: new Text('My second line'),
)
],
);
}
}
class MyBullet extends StatelessWidget{
@override
Widget build(BuildContext context) {
return new Container(
height: 20.0,
width: 20.0,
decoration: new BoxDecoration(
color: Colors.black,
shape: BoxShape.circle,
),
);
}
}
这篇关于如何在flutter中添加项目符号或创建项目符号列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文