记录解决因elevation引起的颜色偏红UI问题

APP页面经历了多个版本迭代,不知是Flutter哪个插件更新版本导致了部分UI颜色偏红!如下图:

滚动前的导航栏(AppBar):
滚动前的导航栏
向上滚动后的导航栏(AppBar):
滚动后的导航栏
PopupMenuButton UI底色偏红
PopupMenuButton

AlertDialog
AlertDialog
解决方案:
在main.dart文件中给MaterialAppGetMaterialApp设置themedarkTheme,此处以GetMaterialApp为例
1)导航栏处理:

runApp(
      GetMaterialApp(
      	  theme: ThemeData(
          appBarTheme: AppBarTheme(
              backgroundColor: Colors.white,
              elevation: 0,
              scrolledUnderElevation: 0,
              systemOverlayStyle: SystemUiOverlayStyle.light),
          scaffoldBackgroundColor: FTColors.greyF8,
          brightness: Brightness.light
        ),
        darkTheme: ThemeData(
          appBarTheme: AppBarTheme(
              backgroundColor: Colors.black,
              elevation: 0,
              scrolledUnderElevation: 0,
              systemOverlayStyle: SystemUiOverlayStyle.dark),
          scaffoldBackgroundColor: FTColors.greyF8,
          brightness: Brightness.dark
        ),
      	)
      );

2)针对每个PopupMenuButton单独处理

PopupMenuButton(
      elevation: 0, //解决菜单背景色偏红问题
      color: Colors.white,
      itemBuilder: (BuildContext context) {
			return [
				PopupMenuItem<String>(
      				  value: "itemId",
				      child: Text(
				        "item"
				      ),
    			)
			];
	   }
)

3)针对每个AlertDialog单独处理

	AlertDialog(
          elevation: 0,
          backgroundColor: Colors.white,
          title: const Text("提示"),
          content: const Text("您已退出登录"),
    )

由于没有找到可以统一处理后两种widget的方法,所以采取了最笨的方式——单独处理。
优先解决问题,后续再优化实现方式

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值