设置AppBar属性:flexibleSpace
AppBar(
title: const Text('XXXXX', style: Styles.pageTitle),
centerTitle: true,
flexibleSpace: Container(
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
ColorConfig.gradient_begin,
ColorConfig.gradient_end,
], begin: Alignment.bottomCenter, end: Alignment.topCenter),
),
),
再去掉状态栏的半透明改为沉浸式后的效果,如图

本文介绍如何在Flutter中为AppBar设置具有渐变效果的背景,并实现状态栏的沉浸式体验。通过设置AppBar的flexibleSpace属性并使用BoxDecoration与LinearGradient结合,可以轻松实现这一效果。
2129

被折叠的 条评论
为什么被折叠?



