gpt4 book ai didi

flutter 数字选择器不会在底部工作表上更新

转载 作者:行者123 更新时间:2023-12-04 08:28:33 27 4
gpt4 key购买 nike

我想在底部工作表对话框中使用 flutter 数字选择器。但是号码选择器
当我通过滑动更改值时不会更新。我的代码如下。

GestureDetector(
onTap: (){
showModalBottomSheet<int>(
context: context,
builder: (BuildContext context){
return new Container(
height: 350.0,
color: HexColor('FF737373'),
child: new Container(
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(20.0),
topRight: const Radius.circular(20.0))),
child: new Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
NumberPicker.integer(
initialValue: _currentValue,
minValue: 0,
maxValue: 1000,
),
],
),
)),
);
}
).then((int value) {
if (value != null) {
setState(() => _currentValue = value);
}
});
},

child: Container(
//container
),
),

最佳答案

我不明白你的目标是什么,但我希望这会有所帮助:

showModalBottomSheet<int>(
context: context,
builder: (BuildContext context){
return StatefulBuilder(
builder: (BuildContext context, StateSetter setModalState) {
return Container(
height: 350.0,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: const Radius.circular(20.0),
topRight: const Radius.circular(20.0)
)
),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
NumberPicker.integer(
initialValue: _currentValue,
minValue: 0,
maxValue: 1000,
onChanged: (value) {
setModalState(() {
_currentValue = value;
});
}
),
],
),
)
),
);
}
);
}
).then((int value) {
if(value != null) {
setState(() => _currentValue = value);
}
});

关于 flutter 数字选择器不会在底部工作表上更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65135874/

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