当前位置: 首页 > news >正文

房产中介网站建设进度建设ftp网站的安全性

房产中介网站建设进度,建设ftp网站的安全性,哈尔滨工程交易信息网,高端大气上档次网站关于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 内部实现。 class RenderViewport extends RenderViewportBaseSliverPhysicalContainerParentData {RenderViewport({super.axisDirection,required super.crossAxisDirection,required super.offset,double anchor 0.0,ListRenderSliver? children,RenderSliver? center,super.cacheExtent,super.cacheExtentStyle,super.clipBehavior,}) 这里我们重点关注offset这个参数其他参数不是本篇内容考虑的范围这个参数在刚刚Viewport 里面赋值这个参数是重点后面会用到。 我们知道RenderViewport管理一个ListRenderSliver 列表列表内容滚动就是该父组件对子组件列表重新布局的结果我们直接找到其performLayou方法 overridevoid performLayout() {......int count 0;do {assert(offset.pixels ! null);correction _attemptLayout(mainAxisExtent, crossAxisExtent, offset.pixels centerOffsetAdjustment);if (correction ! 0.0) {offset.correctBy(correction);} else {if (offset.applyContentDimensions(math.min(0.0, _minScrollExtent mainAxisExtent * anchor),math.max(0.0, _maxScrollExtent - mainAxisExtent * (1.0 - anchor)),)) {break;}}count 1;} while (count _maxLayoutCycles);......}());} performLayout方法中  correction _attemptLayout(mainAxisExtent, crossAxisExtent, offset.pixels centerOffsetAdjustment); 是我们关注的重点。 double _attemptLayout(double mainAxisExtent, double crossAxisExtent, double correctedOffset) {......// positive scroll offsetsreturn layoutChildSequence(child: center,scrollOffset: math.max(0.0, -centerOffset),overlap: leadingNegativeChild null ? math.min(0.0, -centerOffset) : 0.0,layoutOffset: centerOffset mainAxisExtent ? centerOffset: reverseDirectionRemainingPaintExtent,remainingPaintExtent: forwardDirectionRemainingPaintExtent,mainAxisExtent: mainAxisExtent,crossAxisExtent: crossAxisExtent,growthDirection: GrowthDirection.forward,advance: childAfter,remainingCacheExtent: forwardDirectionRemainingCacheExtent,cacheOrigin: clampDouble(centerOffset, -_calculatedCacheExtent!, 0.0),);} 我们找到了layoutChildSequence方法从方法名就能知道这个方法功能就是对子组件列表按照顺序重新布局的。 protecteddouble layoutChildSequence({required RenderSliver? child,required double scrollOffset,required double overlap,required double layoutOffset,required double remainingPaintExtent,required double mainAxisExtent,required double crossAxisExtent,required GrowthDirection growthDirection,required RenderSliver? Function(RenderSliver child) advance,required double remainingCacheExtent,required double cacheOrigin,}) {......while (child ! null) {......child.layout(SliverConstraints(axisDirection: axisDirection,growthDirection: growthDirection,userScrollDirection: adjustedUserScrollDirection,scrollOffset: sliverScrollOffset,precedingScrollExtent: precedingScrollExtent,overlap: maxPaintOffset - layoutOffset,remainingPaintExtent: math.max(0.0, remainingPaintExtent - layoutOffset initialLayoutOffset),crossAxisExtent: crossAxisExtent,crossAxisDirection: crossAxisDirection,viewportMainAxisExtent: mainAxisExtent,remainingCacheExtent: math.max(0.0, remainingCacheExtent cacheExtentCorrection),cacheOrigin: correctedCacheOrigin,), parentUsesSize: true);......// move on to the next childchild advance(child);}// we made it without a correction, whee!return 0.0;} 这个方法就是在不停循环获取下一个child直到最后一个需要布局的child组件。 大体流程就是这样的细心的你一定发现上面没有说明组件是如何根据手指滑动滚动的也就是如何触发RenderViewport 执行performLayout方法。 不要急下面就来说明这一点。 还记得上面提到的offset这个参数吗重头戏就是它。 set offset(ViewportOffset value) {assert(value ! null);if (value _offset) {return;}if (attached) {_offset.removeListener(markNeedsLayout);}_offset value;if (attached) {_offset.addListener(markNeedsLayout);}// We need to go through layout even if the new offset has the same pixels// value as the old offset so that we will apply our viewport and content// dimensions.markNeedsLayout();} 当上面我们给RenderViewport 配置offset参数是offset是一个ChangeNotifer 可以添加变化监听 abstract class ViewportOffset extends ChangeNotifier {/// Default constructor.////// Allows subclasses to construct this object directly.ViewportOffset(); ...... } 当offset 只有的变量更新后通知监听它的回调函数markNeedsLayout这里就回到了Flutter组件渲染大流程里面了。 这个流程下来是不是非常巧妙希望大家阅读完后也能写出如此巧妙的架构。
http://www.hkea.cn/news/14332999/

相关文章:

  • 开个网站做代理赚钱吗百度seo优化软件
  • 公司备案查询网站备案有哪些可以做推广的网站
  • 支持微信支付的网站开发网站优化seo是什么
  • 自己架设服务器做网站如何做漂亮的网站首页
  • 做网站网站危险吗网站开发源代码
  • 网站改版的好处上海网站制作 公司
  • 网站开发最好用什么语言谷歌seo知识
  • 注册域名建设网站免费做app和网站的平台有哪些
  • 上海做网站yuanmuswordpress怎么用万网域名
  • 中国建设银行龙卡信用卡网站网页设计作品展
  • 旅游网站设计风格国际网站建设公司
  • 设计师网站崩了企业网站制作的方法
  • 如何开网站需要多少钱精准客户电话号码资源
  • 建设银行网站首页口用jsp做网站的难点
  • 东莞天助网的网站旅游网站 功能
  • 手表哪个网站正品360推广助手
  • 郑州网站设计专家天津网络推广网站建设公司
  • 专门提供做ppt小素材的网站2013一汽大众企业网站车主俱乐部建设维护方案
  • 网站建设需求有什么用中国建设银行信用卡网站
  • jquery做的网站互联网获客
  • tp框架做展示网站网站开发价格明细
  • php 做网站 python哈尔滨市人社app
  • 给网站做翻译营销词汇100个
  • 佛山网站制作专业公司wordpress 主题js
  • 网站维护的要求手机排行榜2022最新
  • 网站为什么要备案58同城网站建设案例
  • 使用django建设一个网站做公司网站 烟台
  • 男男互做网站我在学校志愿队做网站的经历
  • 怀柔网站制作wordpress批量导入文章cvs
  • 深圳专业做网站技术用户界面设计原则软件开发工具