gpt4 book ai didi

android - Flutter CupertinoTimerPicker不适合父级宽度或高度

转载 作者:行者123 更新时间:2023-12-03 03:57:38 25 4
gpt4 key购买 nike

我尝试使用double.infinity,SizedBox和SizeBox.expand设置宽度和高度的容器。该小部件不适合父级宽度和高度。有人可以帮忙吗?

enter image description here

class _SetTimerButtonState extends State<SetTimerButton> {
List<String> _timerPicker = ["0", "1", "2", "3"];
Duration initialtimer = new Duration();

@override
Widget build(BuildContext context) {
return Builder(
builder: (context) => FlatButton(
color: Colors.white,
textColor: Colors.grey,
disabledColor: Colors.grey,
disabledTextColor: Colors.black,
// padding: EdgeInsets.all(8.0),
// splashColor: Colors.blueAccent,
onPressed: () {
showModalBottomSheet(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
),
context: context,
builder: (BuildContext builder) {
return Container(
height: MediaQuery.of(context).copyWith().size.height / 3,
child: SizedBox.expand(
// height: double.infinity,
// width: double.infinity,
child: CupertinoTimerPicker(
mode: CupertinoTimerPickerMode.hms,
minuteInterval: 1,
secondInterval: 1,
initialTimerDuration: initialtimer,
onTimerDurationChanged: (Duration changedtimer) {
setState(() {
initialtimer = changedtimer;
});
},
),
)
);
}
);
},
child: Row(
children: <Widget>[
Expanded(
child: Text(
"No Timer",
style: TextStyle(fontSize: 20.0),
),
),
Icon(Icons.arrow_forward_ios),
],
),
)
);
}
}

最佳答案

根据documentation,选择器的大小是固定的:

The picker has a fixed size of 320 x 216, in logical pixels, with the exception of CupertinoTimerPickerMode.hms, which is 330 x 216. If the parent widget provides more space than it needs, the picker will position itself according to its alignment property.

关于android - Flutter CupertinoTimerPicker不适合父级宽度或高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59877537/

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