Flutter Slider - 不显示标签
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flutter Slider - 不显示标签相关的知识,希望对你有一定的参考价值。
我有这个滑块,但它没有在任何地方显示标签。
这是正常行为吗?
double _value;
_buildEditModeWidget() {
return Expanded(
child: Column(
children: <Widget>[
SizedBox(height: 60,),
Slider(
label: "Power: ",
min: 0,
max: 9,
value: _value,
onChanged: (double newValue) {
setState(() {
_value = newValue;
});
},
)
],
));
}
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(border: Border(top: BorderSide(width: 1))),
height: editMode ? _editModeHeight : _readOnlyHeight,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8),
child: AspectRatio(
aspectRatio: 0.9,
child: (extension(widget.model.team.shieldImage) != ".svg")
? Image.network(
widget.model.team.shieldImage,
fit: BoxFit.scaleDown,
filterQuality: FilterQuality.high,
)
: SvgPicture.network(
widget.model.team.shieldImage,
fit: BoxFit.scaleDown,
),
),
),
ScopedModelDescendant<TeamModel>(
builder: (BuildContext context, Widget child, TeamModel model) {
return editMode ? _buildEditModeWidget() : _buildReadOnlyWidget();
},
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
child: editMode
? IconButton(
icon: Icon(Icons.check),
onPressed: () {
setState(() {
widget.model.updateTeam(_teamNameController.text, 0);
editMode = false;
});
},
)
: IconButton(
key: _key,
icon: Icon(Icons.edit),
onPressed: () {
setState(() {
editMode = true;
});
},
),
)
],
)
],
),
);
}
答案
尝试将divisions值设置为9.您将在值的每一步上看到标签。看起来这个标签属性不是滑块的文本标签。
以上是关于Flutter Slider - 不显示标签的主要内容,如果未能解决你的问题,请参考以下文章