【发布时间】:2020-05-09 15:57:27
【问题描述】:
我使用 double.infinity、SizedBox 和 SizeBox.expand 尝试了具有宽度和高度的容器。小部件不适合父宽度和高度。有人可以帮忙吗?
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),
],
),
)
);
}
}
【问题讨论】:
标签: android flutter dart flutter-layout