Flutter中设置BottomSheet背景色

BottomSheet底部弹框的背景色与主题的画布底色一致,因此只需修改App主题的canvasColor即可

参考:https://stackoverflow.com/questions/51204179/how-to-change-the-background-color-of-bottomsheet-in-flutter
参考:https://stackoverflow.com/questions/52663445/flutter-show-bottomsheet-transparency

在main.dart中

1
2
3
4
5
6
7
8
9
10
11
12
13
@override
Widget build(BuildContext context) {
return new MaterialApp(
theme: new ThemeData(
primaryColor: themeColor,
canvasColor: Colors.transparent // 设置透明
),
home: MainPage(),
routes: {
'/sign_in': (BuildContext context) => new SignInPage(),
},
);
}

在pages/main_page.dart中

1
2
3
4
5
6
7
@override
Widget build(BuildContext context) {
return new Scaffold(
backgroundColor: Colors.white, // 设置页面背景
body: ...,
);
}

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :