gpt4 book ai didi

flutter - 如何 SliverAppBar 始终显示阴影 - 扩展模式

转载 作者:行者123 更新时间:2023-12-01 23:13:01 24 4
gpt4 key购买 nike

由于 elevation 属性,我正在使用 折叠时有阴影(滚动列表)的 SliverAppBar,但我也希望在 SliverAppBar 展开

class SuperSliverAppBar extends StatelessWidget {
const SuperSliverAppBar({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return SliverAppBar(
pinned: true,
floating: false,
snap: false,
backgroundColor: Colors.grey[200],
collapsedHeight: 90,
expandedHeight: 200,
elevation: 0,
centerTitle: false,
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Mr Mister",
style: TextStyle(
color: Colors.black,
fontSize: 22,
),
textAlign: TextAlign.left),
Row(
children: [
Text("Hello Mister",
style: TextStyle(
color: Colors.black,
fontFamily: 'Lato',
fontWeight: FontWeight.w300,
fontSize: 19,
),
textAlign: TextAlign.left),
SizedBox(width: 10),
Container(
height: 20,
width: 20,
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.all(Radius.circular(1))),
child: Center(
child: Text("",
style: TextStyle(color: Colors.white, fontSize: 10))))
],
),
],
),
//Shape is defined here
shape: const ContinuousRectangleBorder(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(100),
bottomRight: Radius.circular(100))),
flexibleSpace: FlexibleSpaceBar(
collapseMode: CollapseMode.none,
background: Container(),
centerTitle: true,
),
);
}
}

🙏

最佳答案

SliverAppBar 上使用 forceElevated: true,,默认为 false。

Defaults to false, meaning that the [elevation] is only applied when the[AppBar] is being displayed over content that is scrolled under it.
When set to true, the [elevation] is applied regardless.

   return SliverAppBar(
forceElevated: true, //* here
elevation: 20, //* question having 0 here
pinned: true,
floating: false,

它能解决您的问题吗?

关于flutter - 如何 SliverAppBar 始终显示阴影 - 扩展模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69489331/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com