![](/img/trans.png)
[英]How to create SliverAppBar with custom app bar and image in Flutter?
[英]How to fix the custom app bar height wrapped in SliverAppBar Flutter
我正在尝试在滚动隐藏时开发应用栏。我已成功创建但应用栏很小
@override
Widget build(BuildContext context) {
return Scaffold(
body: NestedScrollView(
headerSliverBuilder: (context, innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
backgroundColor: Colors.transparent,
title: PreferredSize(
child: ClipPath(
clipper: CustomAppBar(),
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
' Bike Guru',
style: GoogleFonts.caveatBrush(
fontSize: 40,
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
],
),
),
),
preferredSize: Size.fromHeight(kToolbarHeight + 350)),
floating: true,
pinned: false,
),
];
},
自定义应用条形码
class CustomAppBar extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = new Path();
path.lineTo(0, size.height);
path.quadraticBezierTo(
size.width / 4, size.height - 40, size.width / 2, size.height - 20);
path.quadraticBezierTo(
3 / 4 * size.width, size.height, size.width, size.height - 20);
path.lineTo(size.width, 0);
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
return false;
} }
这只是您可能需要SliverPersistentHeader
小部件来修复高度和宽度的问题的概述
NestedScrollView(
physics: NeverScrollableScrollPhysics(),
controller: this._scrollController1,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverPersistentHeader(
floating: false,
pinned: false,
delegate: SliverAppBarDelegate(
minHeight: AppConfig.trendHeaderImageHeight,
maxHeight: AppConfig.trendHeaderImageHeight,
child: trendingHeader,
)
)
];
},
body: CustomScrollView(
controller: this._scrollController2
...
),
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.