gpt4 book ai didi

dart - 如何使 slider 离散?

转载 作者:行者123 更新时间:2023-12-03 03:26:16 35 4
gpt4 key购买 nike

如何在 Flutter 中使 slider 离散看起来像上图?
slider discrete

最佳答案

使用 divisions Slider 的属性(property)小部件将其分成相等的部分,然后你必须把 Text它们下面的小部件:

 Container(
width: MediaQuery.of(context).size.width,
height: 200.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[

Slider(min: 0.0, max: 1.0, divisions: 9, value: 0.0, onChanged: null); // you have to provide an `onChanged` function to let slider pointer change place, and to execute other related actions.

Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,

children: <Widget>[
Container(
child: Text('6'),
),
Container(
child: Text('7'),
),
Container(
child: Text('8'),
),
Container(
child: Text('9'),
),
Container(
child: Text('10'),
),
Container(
child: Text('11'),
),
Container(
child: Text('12'),
),
Container(
child: Text('13'),
),
Container(
child: Text('14'),
),
]
),
]),
)

关于dart - 如何使 slider 离散?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55061751/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com