我想显示一个 AlertDialog 来提示用户选择颜色。我做到了,但是,ColorPicker 和操作按钮之间有很多空白:
如何删除空白并使对话框达到应有的大小?我尝试过使用 aDialog而不是 an AlertDialog,并将我的内容包装在 a 中Column并mainAxisSize设置为MainAxisSize.min,但都不起作用。一件奇怪的事情是,传递给的值contentPadding似乎对 UI 没有影响。我尝试了不同的值,但它保持不变。
这是代码:
void _showColorPickerDialog() {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
contentPadding: const EdgeInsets.all(6.0),
title: Text('Pick a color'),
content: MaterialColorPicker(),
actions: [
FlatButton(
child: Text('CANCEL', style: TextStyle(color: Colors.blue)),
onPressed: Navigator.of(context).pop),
FlatButton(
child: Text('OK', style: TextStyle(color: Colors.blue)),
onPressed: Navigator.of(context).pop),
],
);
});
}
Run Code Online (Sandbox Code Playgroud)
(Material ColorPicker) 包的作者提供了一些代码,展示了如何执行此操作,这与我的非常相似,但它也有同样的问题。可能我的Flutter版本和他的不一样。无论如何,你们知道有什么好的方法来解决这个问题吗?提前致谢。
小智 5
也许它可以起作用;为 MaterialColorPicker 函数指定高度
content: Container(height:250, child: MaterialColorPicker(),)
| 归档时间: |
|
| 查看次数: |
2658 次 |
| 最近记录: |