Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }