在使用NestedScrollView构建嵌套布局时,Flutter的Sliver之间存在约1px的间隙,使用下述方案解决:
加入boxShadow
掩盖即可:
NestedScrollView{
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) {
return [
SliverPersistentHeader(
pinned: true,
delegate: SliverXXXDelegate.fixedHeight(
child: Container(
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top),
decoration:
BoxDecoration(color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.white,
blurRadius: 0.0,
spreadRadius: 0.0,
offset: Offset(0, 2),
),
]),
child:...
),
),
)),
SliverPersistentHeader(
pinned: true,
delegate: SliverXXXDelegate.fixedHeight(
child: Container(
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top),
decoration:
BoxDecoration(color: Colors.white, boxShadow: [
BoxShadow(
color: Colors.white,
blurRadius: 0.0,
spreadRadius: 0.0,
offset: Offset(0, 2),
),
]),
child:...
),
),
)),
];
},
body:
{...}
}
参考资料
https://github.com/flutter/flutter/issues/37578#issuecomment-640302364