protected ScrollPosition( ScrollPhysics physics = null, ScrollContext context = null, bool keepScrollOffset = true, ScrollPosition oldPosition = null, string debugLabel = null ) { D.assert(physics != null); D.assert(context != null); D.assert(context.vsync != null); this.physics = physics; this.context = context; this.keepScrollOffset = keepScrollOffset; this.debugLabel = debugLabel; if (oldPosition != null) { this.absorb(oldPosition); } if (keepScrollOffset) { this.restoreScrollOffset(); } }
public ScrollPositionWithSingleContext( ScrollPhysics physics = null, ScrollContext context = null, float?initialPixels = 0.0f, bool keepScrollOffset = true, ScrollPosition oldPosition = null, string debugLabel = null ) : base( physics: physics, context: context, keepScrollOffset: keepScrollOffset, oldPosition: oldPosition, debugLabel: debugLabel ) { if (this._pixels == null && initialPixels != null) { this.correctPixels(initialPixels.Value); } if (this.activity == null) { this.goIdle(); } D.assert(this.activity != null); }
void _updatePosition() { this._configuration = ScrollConfiguration.of(this.context); this._physics = this._configuration.getScrollPhysics(this.context); if (this.widget.physics != null) { this._physics = this.widget.physics.applyTo(this._physics); } ScrollController controller = this.widget.controller; ScrollPosition oldPosition = this.position; if (oldPosition != null) { if (controller != null) { controller.detach(oldPosition); } Window.instance.scheduleMicrotask(oldPosition.dispose); } this._position = controller == null ? null : controller.createScrollPosition(this._physics, this, oldPosition); this._position = this._position ?? new ScrollPositionWithSingleContext(physics: this._physics, context: this, oldPosition: oldPosition); D.assert(this.position != null); if (controller != null) { controller.attach(this.position); } }
public override void attach(ScrollPosition position) { base.attach(position); _PagePosition pagePosition = (_PagePosition)position; pagePosition.viewportFraction = viewportFraction; }
float _getPixels(ScrollPosition position, float page) { if (position is _PagePosition) { return(((_PagePosition)position).getPixelsFromPage(page)); } return(page * position.viewportDimension); }
float _getPage(ScrollPosition position) { if (position is _PagePosition) { return(((_PagePosition)position).page); } return(position.pixels / position.viewportDimension); }
public override ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition oldPosition) { return(new _FixedExtentScrollPosition( physics: physics, context: context, initialItem: this.initialItem, oldPosition: oldPosition )); }
public override void attach(ScrollPosition position) { base.attach(position); D.assert(!this._positionToListener.ContainsKey(position)); this._positionToListener[position] = () => { this._lastUpdated = position; this._lastUpdatedOffset = position.pixels; }; position.addListener(this._positionToListener[position]); }
public override ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition oldPosition) { return(new _PagePosition( physics: physics, context: context, initialPage: this.initialPage, keepPage: this.keepPage, viewportFraction: this.viewportFraction, oldPosition: oldPosition )); }
internal _ScrollableScope( Key key = null, ScrollableState scrollable = null, ScrollPosition position = null, Widget child = null ) : base(key: key, child: child) { D.assert(scrollable != null); D.assert(child != null); this.scrollable = scrollable; this.position = position; }
public TestScrollPositionWithSingleContext( ScrollPhysics physics = null, ScrollContext context = null, float?initialPixels = 0.0f, bool keepScrollOffset = true, ScrollPosition oldPosition = null, string debugLabel = null ) : base(physics: physics, context: context, keepScrollOffset: keepScrollOffset, oldPosition: oldPosition, debugLabel: debugLabel) { }
float _getTargetPixels(ScrollPosition position, Tolerance tolerance, float velocity) { float page = this._getPage(position); if (velocity < -tolerance.velocity) { page -= 0.5f; } else if (velocity > tolerance.velocity) { page += 0.5f; } return(this._getPixels(position, page.round())); }
double _getTargetPixels(ScrollPosition position, Tolerance tolerance, double velocity) { double page = this._getPage(position); if (velocity < -tolerance.velocity) { page -= 0.5; } else if (velocity > tolerance.velocity) { page += 0.5; } return(this._getPixels(position, page.round())); }
public virtual ScrollPosition createScrollPosition( ScrollPhysics physics, ScrollContext context, ScrollPosition oldPosition ) { return(new ScrollPositionWithSingleContext( physics: physics, context: context, initialPixels: this.initialScrollOffset, keepScrollOffset: this.keepScrollOffset, oldPosition: oldPosition, debugLabel: this.debugLabel )); }
public override void detach(ScrollPosition position) { base.detach(position); D.assert(this._positionToListener.ContainsKey(position)); position.removeListener(this._positionToListener[position]); this._positionToListener.Remove(position); if (this._lastUpdated == position) { this._lastUpdated = null; } if (this._positionToListener.isEmpty()) { this._lastUpdatedOffset = null; } }
internal _PagePosition( ScrollPhysics physics = null, ScrollContext context = null, int initialPage = 0, bool keepPage = true, float viewportFraction = 1.0f, ScrollPosition oldPosition = null ) : base( physics: physics, context: context, initialPixels: null, keepScrollOffset: keepPage, oldPosition: oldPosition ) { D.assert(viewportFraction > 0.0); this.initialPage = initialPage; _viewportFraction = viewportFraction; _pageToUseOnStartup = initialPage; }
protected override void absorb(ScrollPosition other) { base.absorb(other); if (!(other is ScrollPositionWithSingleContext)) { this.goIdle(); return; } this.activity.updateDelegate(this); ScrollPositionWithSingleContext typedOther = (ScrollPositionWithSingleContext)other; this._userScrollDirection = typedOther._userScrollDirection; D.assert(this._currentDrag == null); if (typedOther._currentDrag != null) { this._currentDrag = typedOther._currentDrag; this._currentDrag.updateDelegate(this); typedOther._currentDrag = null; } }
public _FixedExtentScrollPosition( ScrollPhysics physics, ScrollContext context, int initialItem, bool keepScrollOffset = true, ScrollPosition oldPosition = null, string debugLabel = null ) : base( physics: physics, context: context, initialPixels: _getItemExtentFromScrollContext(context) * initialItem, keepScrollOffset: keepScrollOffset, oldPosition: oldPosition, debugLabel: debugLabel ) { D.assert( context is _FixedExtentScrollableState, () => "FixedExtentScrollController can only be used with ListWheelScrollViews" ); }
void _updatePosition() { _configuration = ScrollConfiguration.of(context); _physics = _configuration.getScrollPhysics(context); if (widget.physics != null) { _physics = widget.physics.applyTo(_physics); } ScrollController controller = widget.controller; ScrollPosition oldPosition = position; if (oldPosition != null) { if (controller != null) { controller.detach(oldPosition); } async_.scheduleMicrotask(() => { oldPosition.dispose(); return(null); }); } if (controller == null) { _position = new ScrollPositionWithSingleContext(physics: _physics, context: this, oldPosition: oldPosition); } else { _position = controller?.createScrollPosition(_physics, this, oldPosition) ?? new ScrollPositionWithSingleContext(physics: _physics, context: this, oldPosition: oldPosition); } D.assert(position != null); if (controller != null) { controller.attach(position); } }
protected virtual void absorb(ScrollPosition other) { D.assert(other != null); D.assert(other.context == this.context); D.assert(this._pixels == null); this._minScrollExtent = other.minScrollExtent; this._maxScrollExtent = other.maxScrollExtent; this._pixels = other._pixels; this._viewportDimension = other.viewportDimension; D.assert(this.activity == null); D.assert(other.activity != null); this._activity = other.activity; other._activity = null; if (other.GetType() != this.GetType()) { this.activity.resetActivity(); } this.context.setIgnorePointer(this.activity.shouldIgnorePointer); this.isScrollingNotifier.value = this.activity.isScrolling; }
public virtual void attach(ScrollPosition position) { D.assert(!this._positions.Contains(position)); this._positions.Add(position); position.addListener(this.notifyListeners); }
public virtual void detach(ScrollPosition position) { D.assert(this._positions.Contains(position)); position.removeListener(this.notifyListeners); this._positions.Remove(position); }