public override Widget build(BuildContext context) { AxisDirection?axisDirection = _getDirection(context); ScrollPhysics physics = new _ForceImplicitScrollPhysics( allowImplicitScrolling: widget.allowImplicitScrolling ).applyTo(widget.pageSnapping ? PageViewUtils._kPagePhysics.applyTo(widget.physics) : widget.physics); return(new NotificationListener <ScrollNotification>( onNotification: (ScrollNotification notification) => { if (notification.depth == 0 && widget.onPageChanged != null && notification is ScrollUpdateNotification) { IPageMetrics metrics = (IPageMetrics)notification.metrics; int currentPage = metrics.page.round(); if (currentPage != _lastReportedPage) { _lastReportedPage = currentPage; widget.onPageChanged(currentPage); } } return false; }, child: new Scrollable( dragStartBehavior: widget.dragStartBehavior, axisDirection: axisDirection, controller: widget.controller, physics: physics, viewportBuilder: (BuildContext _context, ViewportOffset position) => { return new Viewport( cacheExtent: widget.allowImplicitScrolling ? 1.0f : 0.0f, cacheExtentStyle: CacheExtentStyle.viewport, axisDirection: axisDirection, offset: position, slivers: new List <Widget> { new SliverFillViewport( viewportFraction: widget.controller.viewportFraction, _delegate: widget.childrenDelegate ) } ); } ) )); }
public override Widget build(BuildContext context) { AxisDirection axisDirection = this._getDirection(context); ScrollPhysics physics = this.widget.pageSnapping ? PageViewUtils._kPagePhysics.applyTo(this.widget.physics) : this.widget.physics; return(new NotificationListener <ScrollNotification>( onNotification: (ScrollNotification notification) => { if (notification.depth == 0 && this.widget.onPageChanged != null && notification is ScrollUpdateNotification) { IPageMetrics metrics = (IPageMetrics)notification.metrics; int currentPage = metrics.page.round(); if (currentPage != this._lastReportedPage) { this._lastReportedPage = currentPage; this.widget.onPageChanged(currentPage); } } return false; }, child: new Scrollable( axisDirection: axisDirection, controller: this.widget.controller, physics: physics, viewportBuilder: (BuildContext _context, ViewportOffset position) => { return new Viewport( cacheExtent: 0.0f, axisDirection: axisDirection, offset: position, slivers: new List <Widget> { new SliverFillViewport( viewportFraction: this.widget.controller.viewportFraction, del: this.widget.childrenDelegate ) } ); } ) )); }