小编dis*_*den的帖子

如何在Flutter中更改BottomSheet的背景颜色?

屏幕截图

当我使用showModalBottomSheet方法弹出bottomSheet时,如何使背景色透明。因为我需要圆角,所以我知道在materialApp中更改canvasColor可以解决问题,但是其他小部件也可以更改颜色。

我试图将其嵌入主题中,但是没有用

showModalBottomSheet < Null > (context: context, builder: (BuildContext context) {
    return Theme(
        data: Theme.of(context).copyWith(canvasColor: Colors.orange),
        child: Material(
            borderRadius: BorderRadius.only(topLeft: Radius.circular(16.0), topRight: Radius.circular(16.0)),
            child: Container(
                color: Colors.purple,
            ),
        ),
    );
});
Run Code Online (Sandbox Code Playgroud)

flutter

2
推荐指数
4
解决办法
3117
查看次数

标签 统计

flutter ×1