当前位置:   article > 正文

[已解决]消除Flutter Sliver之间存在的间隙_sliverchildbuilderdelegate 多张图片之间缝隙

sliverchildbuilderdelegate 多张图片之间缝隙

在使用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:
		{...}
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48

参考资料

https://github.com/flutter/flutter/issues/37578#issuecomment-640302364

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/463084
推荐阅读
相关标签
  

闽ICP备14008679号