Flutter AppBar导航栏透明

AppBar 透明需要在Scaffold 下面

透明有两种情况

第一种 以这个为例子 这种全透明

实现思路就是

return Scaffold(

extendBodyBehindAppBar: true,//主要代码为extendBodyBehindAppBar 这个属性

appBar: AppBar(

centerTitle: true,

// 标题居中

backgroundColor: Colors.transparent,

// 背景颜色设置为透明

shadowColor: Colors.transparent,

// 阴影也要设置为透明

//把AppBar 设置为透明色

elevation: 0,

),

body: Container(

//设置背景图背景图覆盖整个就可以做到上面图的效果

image: DecorationImage(

image: AssetImage('assets/images/dialog_success.png'),

fit: BoxFit.fill, // 完全填充

),

第二种就是 滑动时导航栏透明

实现思路和上面大致

return Scaffold(

extendBodyBehindAppBar: true,//主要代码为extendBodyBehindAppBar 这个属性

appBar: AppBar(

centerTitle: true,

// 标题居中

backgroundColor: Colors.transparent,

// 背景颜色设置为透明

shadowColor: Colors.transparent,

// 阴影也要设置为透明

//把AppBar 设置为透明色

elevation: 0,

),

//Stack 这个可以固定底部导航栏

body: Stack(

children: [

ListView.builder(

内容

),

//底部导航栏

Positioned(

left: 0,

right: 0,

bottom: 0,

child: Container(

// height: 20,

padding: EdgeInsets.all(5),

decoration: BoxDecoration(

border: Border.all(width: 1.0, color: Colors.white),

color: Colors.white),

child: Row(

mainAxisAlignment: MainAxisAlignment.spaceBetween,

children: [

Container(

padding: EdgeInsets.all(10),

// child: Text(data.l.chapterName.toString()), 如果需要可以自己开放

),

ElevatedButton(

onPressed: () {},

style: ElevatedButton.styleFrom(

primary: Colors.yellow,

elevation: 0,

minimumSize: const Size(0, 35),

shape: const StadiumBorder(),

textStyle: const TextStyle(fontSize: 14),

),

child: const Text(

'开始阅读',

style: TextStyle(color: Colors.black),

),

)

],

),

),

),

]

),

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值