showModalBottomSheet 和边框半径

Jsa*_*ncs 1 dart flutter

我想showModalBottomSheet在 Flutter 中制作一个带有容器的容器。我希望这个容器有圆形的顶部边框,但是,当我尝试这个时,角落里有一些小的无色空间。我怎样才能删除它们?

这是我使用的代码:

class OverlayWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ElevatedButton(
      child: const Text('showModalBottomSheet'),
      onPressed: () {
        showModalBottomSheet(
          context: context,
          isScrollControlled: true,
          builder: (BuildContext context) {
            return Container(
              height: MediaQuery.of(context).size.height * 0.80,
              decoration: BoxDecoration(
                color: Colors.green,
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(30.0),
                  topRight: Radius.circular(30.0),
                ),
              ),
              child: Center(...),
            );
          },
        );
      },
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

结果如下: 在此输入图像描述

我想删除顶部边框的空白。谢谢。

Jsa*_*ncs 5

查看文档,我意识到该showModalBottomSheet<T>函数有一个名为backgroundColor\xe2\x80\x8d\xe2\x99\x80\xef\xb8\x8f 的属性

\n

只需添加:

\n
backgroundColor: Colors.transparent,\n
Run Code Online (Sandbox Code Playgroud)\n

showModalBottomSheet作品。

\n

不管怎样,谢谢你的帮助!

\n