如何创建肇庆微网站并添加地图功能?
摘要:肇庆微网站,制作地图的网站,wordpress 国内 模板,石家庄外贸网站建设公司排名关于Flutter Sliver组件内容可以参考下面这位博主博客,写的已经非常好了,这里就不再
肇庆微网站,制作地图的网站,wordpress 国内 模板,石家庄外贸网站建设公司排名关于Flutter Sliver组件内容可以参考下面这位博主博客#xff0c;写的已经非常好了#xff0c;这里就不再赘述。
38、Flutter之 可滚动组件简介_flutter 可滑动_风雨「83」的博客-CSDN博客 通过阅读上面的博客#xff0c;我们已经知道了Scrollable和Viewport基础概念#…关于Flutter Sliver组件内容可以参考下面这位博主博客写的已经非常好了这里就不再赘述。
38、Flutter之 可滚动组件简介_flutter 可滑动_风雨「83」的博客-CSDN博客 通过阅读上面的博客我们已经知道了Scrollable和Viewport基础概念接下来跟随作者一起结合Flutter源码分析下ViewPort是如何滚动。
先看一个简单的demo
MaterialApp(home: Scaffold(body: Center(child: Container(height: 300,child: Scrollable(viewportBuilder: (BuildContext context, ViewportOffset position) {return Viewport(offset: position,slivers: [SliverToBoxAdapter(child: Container(width: 100,height: 100,color: Colors.lightBlue,),),SliverToBoxAdapter(child: Container(width: 100,height: 100,color: Colors.pink,),),SliverToBoxAdapter(child: Container(width: 100,height: 100,color: Colors.green,),),SliverToBoxAdapter(child: Container(width: 100,height: 100,color: Colors.black,),),SliverToBoxAdapter(child: Container(width: 100,height: 100,color: Colors.red,),)],);},))),),)
就是一个简单的滚动列表可以上下滚动。 上面是一个简单的滚动列表当手指触摸屏幕时内容随之发上移动滚动。
下面我们从Flutter刷新机制来梳理下列表里面的组件是在什么时机由谁触发重新布局的组件的位移就是重新布局的体现。
class Viewport extends MultiChildRenderObjectWidget {......overrideRenderViewport createRenderObject(BuildContext context) {return RenderViewport(axisDirection: axisDirection,crossAxisDirection: crossAxisDirection ?? Viewport.getDefaultCrossAxisDirection(context, axisDirection),anchor: anchor,offset: offset,cacheExtent: cacheExtent,cacheExtentStyle: cacheExtentStyle,clipBehavior: clipBehavior,);}overridevoid updateRenderObject(BuildContext context, RenderViewport renderObject) {renderObject..axisDirection axisDirection..crossAxisDirection crossAxisDirection ?? Viewport.getDefaultCrossAxisDirection(context, axisDirection)..anchor anchor..offset offset..cacheExtent cacheExtent..cacheExtentStyle cacheExtentStyle..clipBehavior clipBehavior;}
Viewport 继承MultiChildRenderObjectWidget与之对应的RenderObject是RenderViewport相关布局逻辑肯定是在RenderViewport 内部实现。
