flutter - 我怎样才能像这张图片一样将小部件放在银条应用栏上方
解决方案
所以你有两个选择,第一个,这是我写下一个例子的那个,是你SliverAppBar
包含Stack
一个有图像和电影标题容器的,它与主体颜色相同,所以它显示为一个容器((用绿色边框来说明))。这将使应用栏消失,就像我猜想的那样。
第二种选择是您不使用应用栏,并且页面将仅包含一个很大的主体,Container
您将对上面的堆栈执行相同的操作。
我希望这就是你要找的。
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBar(
primary: true,
pinned: false,
backgroundColor: Colors.white,
expandedHeight: MediaQuery.of(context).size.height * 0.45,
flexibleSpace: FlexibleSpaceBar(
collapseMode: CollapseMode.pin,
background: Container(
decoration: BoxDecoration(border: Border.all(color: Colors.green)),
child: Stack(
children: [
Container(
decoration: BoxDecoration(
color: Colors.black,
image: DecorationImage(
fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.grey.withOpacity(0.5), BlendMode.dstATop),
alignment: Alignment.topCenter,
image: NetworkImage(
"https://m.media-amazon.com/images/M/MV5BNDg3MmI1ZDYtMDZjYi00ZWRlLTk4NzEtZjY4Y2U0NjE5YmRiXkEyXkFqcGdeQXVyNzAxMjE1NDg@._V1_UY1200_CR92,0,630,1200_AL_.jpg"),
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 100,
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.symmetric(horizontal: 30, vertical: 20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Gangs of New York",
style: TextStyle(fontSize: 17, fontWeight: FontWeight.w400),
),
Row(
children: [
Container(
decoration: ShapeDecoration(
shape: StadiumBorder(),
color: Colors.grey[400],
),
child: Padding(
padding: const EdgeInsets.all(6),
child: Text("Action"),
),
),
SizedBox(width: 5),
Container(
decoration: ShapeDecoration(
shape: StadiumBorder(),
color: Colors.grey[400],
),
child: Padding(
padding: const EdgeInsets.all(6),
child: Text("etc"),
),
)
],
)
],
),
),
),
Align(
alignment: Alignment.center,
child: Icon(Icons.play_circle_outline, color: Colors.white, size: 50),
)
],
),
),
),
),
SliverToBoxAdapter(
child: Container(
height: 700,
decoration: BoxDecoration(
color: Colors.white,
),
child: Center(
child: Text("body"),
),
),
),
],
),
);
}
推荐阅读
- kubernetes - 保险柜和领事:保险柜存储未显示在领事用户界面中
- solidity - 如何处理solidity视图函数中的返回错误?
- android - Android startActivity Intent 顺序
- git - 如果远程分支不再存在,如何将本地 .repo 文件夹提取到文件中?
- azure - DocumentDB:批量导入存储过程:在 COSMOS DB 中插入多个分区键文档
- arrays - 类型“数字”不可分配给类型类名称 []
- blockchain - 有没有字符串比较的功能
- mysql - 为什么我在 phpmyadmin 上出现此错误:在修订时创建外键时出错(检查数据类型)?
- java - 使用 crashlytics-2.10.1 从 Google 控制台获取 ANR 报告
- ionic4 - Ionic 4. 如何在超级标签中刷新或更新页面