我正在编写一个需要底角为半径的应用程序。您可以在 Google Task 应用中看到类似的内容。
这是我的代码
showModalBottomSheet(
context: context,
builder: (builder) {
return new Container(
height: 350.0,
color: Colors.transparent,
child: new Container(
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(10.0), topRight: const Radius.circular(10.0))),
child: new Center(
child: new Text("This is a modal sheet"),
)),
);
});
仍显示没有边框半径的工作表。
好的,我找到了一个理由。它确实显示圆角,但由于脚手架背景颜色,容器的背景保持白色。现在的问题是如何覆盖脚手架背景颜色。
3 回答
对于仍在尝试解决此问题的人:
由于某些原因
Colors.transparent
不起作用,所以你需要做的就是将颜色改为:Color(0xFF737373)
showModalBottomSheet( context: context, builder: (builder) { return new Container( height: 350.0, color: Color(0xFF737373), child: new Container( decoration: new BoxDecoration( color: Colors.white, borderRadius: new BorderRadius.only( topLeft: const Radius.circular(10.0), topRight: const Radius.circular(10.0))), child: new Center( child: new Text("This is a modal sheet"), )), ); });
好的,所以将我的应用程序主题中的
canvasColor
更改为Colors.transparent
。它看起来像这样:result_1
在
main.dart
中添加以下代码后:它看起来像这样:result_2