public CustomScrollView(
     Key key = null,
     Axis scrollDirection        = Axis.vertical,
     bool reverse                = false,
     ScrollController controller = null,
     bool?primary                = null,
     ScrollPhysics physics       = null,
     bool shrinkWrap             = false,
     Key center            = null,
     float anchor          = 0.0f,
     float?cacheExtent     = null,
     List <Widget> slivers = null,
     DragStartBehavior dragStartBehavior = DragStartBehavior.start
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         center: center,
         anchor: anchor,
         cacheExtent: cacheExtent,
         dragStartBehavior: dragStartBehavior
         )
 {
     this.slivers = slivers ?? new List <Widget>();
 }
 public static GridView builder(
     Key key = null,
     Axis scrollDirection             = Axis.vertical,
     bool reverse                     = false,
     ScrollController controller      = null,
     bool?primary                     = null,
     ScrollPhysics physics            = null,
     bool shrinkWrap                  = false,
     EdgeInsets padding               = null,
     SliverGridDelegate gridDelegate  = null,
     IndexedWidgetBuilder itemBuilder = null,
     int?itemCount                    = null,
     bool addAutomaticKeepAlives      = true,
     bool addRepaintBoundaries        = true,
     float?cacheExtent                = null
     )
 {
     return(new GridView(
                key: key,
                scrollDirection: scrollDirection,
                reverse: reverse,
                controller: controller,
                primary: primary,
                physics: physics,
                shrinkWrap: shrinkWrap,
                padding: padding,
                gridDelegate: gridDelegate,
                itemBuilder: itemBuilder,
                itemCount: itemCount,
                addAutomaticKeepAlives: addAutomaticKeepAlives,
                addRepaintBoundaries: addRepaintBoundaries,
                cacheExtent: cacheExtent
                ));
 }
Exemple #3
0
        protected ScrollView(
            Key key = null,
            Axis scrollDirection        = Axis.vertical,
            bool reverse                = false,
            ScrollController controller = null,
            bool?primary                = null,
            ScrollPhysics physics       = null,
            bool shrinkWrap             = false,
            float?cacheExtent           = null
            ) : base(key: key)
        {
            D.assert(!(controller != null && primary == true),
                     "Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +
                     "You cannot both set primary to true and pass an explicit controller.");

            primary = primary ?? controller == null && scrollDirection == Axis.vertical;
            physics = physics ?? (primary.Value ? new AlwaysScrollableScrollPhysics() : null);

            this.scrollDirection = scrollDirection;
            this.reverse         = reverse;
            this.controller      = controller;
            this.primary         = primary.Value;
            this.physics         = physics;
            this.shrinkWrap      = shrinkWrap;
            this.cacheExtent     = cacheExtent;
        }
        protected ScrollView(
            Key key = null,
            Axis scrollDirection        = Axis.vertical,
            bool reverse                = false,
            ScrollController controller = null,
            bool?primary                = null,
            ScrollPhysics physics       = null,
            bool shrinkWrap             = false,
            Key center        = null,
            float anchor      = 0.0f,
            float?cacheExtent = null,
            DragStartBehavior dragStartBehavior = DragStartBehavior.start
            ) : base(key: key)
        {
            D.assert(!(controller != null && primary == true),
                     () => "Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +
                     "You cannot both set primary to true and pass an explicit controller.");
            D.assert(!shrinkWrap || center == null);
            D.assert(anchor >= 0.0f && anchor <= 1.0f);

            primary = primary ?? controller == null && scrollDirection == Axis.vertical;
            physics = physics ?? (primary.Value ? new AlwaysScrollableScrollPhysics() : null);

            this.scrollDirection   = scrollDirection;
            this.reverse           = reverse;
            this.controller        = controller;
            this.primary           = primary.Value;
            this.physics           = physics;
            this.shrinkWrap        = shrinkWrap;
            this.center            = center;
            this.anchor            = anchor;
            this.cacheExtent       = cacheExtent;
            this.dragStartBehavior = dragStartBehavior;
        }
 public GridView(
     Key key = null,
     Axis scrollDirection                 = Axis.vertical,
     bool reverse                         = false,
     ScrollController controller          = null,
     bool?primary                         = null,
     ScrollPhysics physics                = null,
     bool shrinkWrap                      = false,
     EdgeInsets padding                   = null,
     SliverGridDelegate gridDelegate      = null,
     SliverChildDelegate childrenDelegate = null,
     float?cacheExtent                    = null,
     DragStartBehavior dragStartBehavior  = DragStartBehavior.start
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         padding: padding,
         cacheExtent: cacheExtent,
         dragStartBehavior: dragStartBehavior
         )
 {
     D.assert(gridDelegate != null);
     D.assert(childrenDelegate != null);
     this.gridDelegate     = gridDelegate;
     this.childrenDelegate = childrenDelegate;
 }
Exemple #6
0
 public SingleChildScrollView(
     Key key = null,
     Axis scrollDirection                = Axis.vertical,
     bool reverse                        = false,
     EdgeInsets padding                  = null,
     bool?primary                        = null,
     ScrollPhysics physics               = null,
     ScrollController controller         = null,
     Widget child                        = null,
     DragStartBehavior dragStartBehavior = DragStartBehavior.start
     ) : base(key: key)
 {
     D.assert(!(controller != null && primary == true),
              () =>
              "Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +
              "You cannot both set primary to true and pass an explicit controller.");
     this.scrollDirection   = scrollDirection;
     this.reverse           = reverse;
     this.padding           = padding;
     this.primary           = primary ?? controller == null && scrollDirection == Axis.vertical;
     this.physics           = physics;
     this.controller        = controller;
     this.child             = child;
     this.dragStartBehavior = dragStartBehavior;
 }
Exemple #7
0
        public override Widget build(BuildContext context)
        {
            AxisDirection axisDirection = this._getDirection(context);
            Widget        contents      = this.child;

            if (this.padding != null)
            {
                contents = new Padding(
                    padding: this.padding,
                    child: contents);
            }

            ScrollController scrollController = this.primary
                ? PrimaryScrollController.of(context)
                : this.controller;

            Scrollable scrollable = new Scrollable(
                axisDirection: axisDirection,
                controller: scrollController,
                physics: this.physics,
                viewportBuilder: (BuildContext subContext, ViewportOffset offset) => {
                return(new _SingleChildViewport(
                           axisDirection: axisDirection,
                           offset: offset,
                           child: contents));
            }
                );

            if (this.primary && scrollController != null)
            {
                return(PrimaryScrollController.none(child: scrollable));
            }

            return(scrollable);
        }
 public static GridView custom(
     Key key = null,
     Axis scrollDirection                 = Axis.vertical,
     bool reverse                         = false,
     ScrollController controller          = null,
     bool?primary                         = null,
     ScrollPhysics physics                = null,
     bool shrinkWrap                      = false,
     EdgeInsets padding                   = null,
     SliverGridDelegate gridDelegate      = null,
     SliverChildDelegate childrenDelegate = null,
     float?cacheExtent                    = null,
     DragStartBehavior dragStartBehavior  = DragStartBehavior.start
     )
 {
     return(new GridView(
                key: key,
                scrollDirection: scrollDirection,
                reverse: reverse,
                controller: controller,
                primary: primary,
                physics: physics,
                shrinkWrap: shrinkWrap,
                padding: padding,
                gridDelegate: gridDelegate,
                childrenDelegate: childrenDelegate,
                cacheExtent: cacheExtent,
                dragStartBehavior: dragStartBehavior
                ));
 }
Exemple #9
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);
            }
        }
Exemple #10
0
 public static ListWheelScrollView useDelegate(
     float itemExtent,
     List <Widget> children = null,
     ListWheelChildDelegate childDelegate = null,
     Key key = null,
     ScrollController controller = null,
     ScrollPhysics physics       = null,
     float diameterRatio         = RenderListWheelViewport.defaultDiameterRatio,
     float perspective           = RenderListWheelViewport.defaultPerspective,
     float offAxisFraction       = 0.0f,
     bool useMagnifier           = false,
     float magnification         = 1.0f,
     ValueChanged <int> onSelectedItemChanged = null,
     bool clipToSize = true,
     bool renderChildrenOutsideViewport = false
     )
 {
     return(new ListWheelScrollView(
                itemExtent: itemExtent,
                children: children,
                childDelegate: childDelegate,
                key: key,
                controller: controller,
                physics: physics,
                diameterRatio: diameterRatio,
                perspective: perspective,
                offAxisFraction: offAxisFraction,
                useMagnifier: useMagnifier,
                magnification: magnification,
                onSelectedItemChanged: onSelectedItemChanged,
                clipToSize: clipToSize,
                renderChildrenOutsideViewport: renderChildrenOutsideViewport
                ));
 }
 public ListView(
     Key key = null,
     Axis scrollDirection                = Axis.vertical,
     bool reverse                        = false,
     ScrollController controller         = null,
     bool?primary                        = null,
     ScrollPhysics physics               = null,
     bool shrinkWrap                     = false,
     EdgeInsets padding                  = null,
     float?itemExtent                    = null,
     bool addAutomaticKeepAlives         = true,
     bool addRepaintBoundaries           = true,
     float?cacheExtent                   = null,
     List <Widget> children              = null,
     DragStartBehavior dragStartBehavior = DragStartBehavior.start
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         padding: padding,
         cacheExtent: cacheExtent,
         dragStartBehavior: dragStartBehavior
         )
 {
     this.itemExtent       = itemExtent;
     this.childrenDelegate = new SliverChildListDelegate(
         children,
         addAutomaticKeepAlives: addAutomaticKeepAlives,
         addRepaintBoundaries: addRepaintBoundaries
         );
 }
 public BoxScrollView(
     Key key = null,
     Axis scrollDirection                = Axis.vertical,
     bool reverse                        = false,
     ScrollController controller         = null,
     bool?primary                        = null,
     ScrollPhysics physics               = null,
     bool shrinkWrap                     = false,
     EdgeInsets padding                  = null,
     float?cacheExtent                   = null,
     DragStartBehavior dragStartBehavior = DragStartBehavior.start
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         cacheExtent: cacheExtent,
         dragStartBehavior: dragStartBehavior
         )
 {
     this.padding = padding;
 }
 ListView(
     Key key = null,
     Axis scrollDirection                 = Axis.vertical,
     bool reverse                         = false,
     ScrollController controller          = null,
     bool?primary                         = null,
     ScrollPhysics physics                = null,
     bool shrinkWrap                      = false,
     EdgeInsets padding                   = null,
     float?itemExtent                     = null,
     SliverChildDelegate childrenDelegate = null,
     float?cacheExtent                    = null
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         padding: padding,
         cacheExtent: cacheExtent
         )
 {
     D.assert(childrenDelegate != null);
     this.itemExtent       = itemExtent;
     this.childrenDelegate = childrenDelegate;
 }
 public GridView(
     Key key = null,
     Axis scrollDirection             = Axis.vertical,
     bool reverse                     = false,
     ScrollController controller      = null,
     bool?primary                     = null,
     ScrollPhysics physics            = null,
     bool shrinkWrap                  = false,
     EdgeInsets padding               = null,
     SliverGridDelegate gridDelegate  = null,
     IndexedWidgetBuilder itemBuilder = null,
     int?itemCount                    = null,
     bool addAutomaticKeepAlives      = true,
     bool addRepaintBoundaries        = true,
     float?cacheExtent                = null
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         padding: padding,
         cacheExtent: cacheExtent
         )
 {
     this.gridDelegate     = gridDelegate;
     this.childrenDelegate = new SliverChildBuilderDelegate(
         itemBuilder,
         childCount: itemCount,
         addAutomaticKeepAlives: addAutomaticKeepAlives,
         addRepaintBoundaries: addRepaintBoundaries
         );
 }
 public GridView(
     Key key = null,
     Axis scrollDirection            = Axis.vertical,
     bool reverse                    = false,
     ScrollController controller     = null,
     bool?primary                    = null,
     ScrollPhysics physics           = null,
     bool shrinkWrap                 = false,
     EdgeInsets padding              = null,
     SliverGridDelegate gridDelegate = null,
     bool addAutomaticKeepAlives     = true,
     bool addRepaintBoundaries       = true,
     float?cacheExtent               = null,
     List <Widget> children          = null
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         padding: padding,
         cacheExtent: cacheExtent
         )
 {
     D.assert(gridDelegate != null);
     this.childrenDelegate = new SliverChildListDelegate(
         children ?? new List <Widget>(),
         addAutomaticKeepAlives: addAutomaticKeepAlives,
         addRepaintBoundaries: addRepaintBoundaries
         );
 }
 public static ListView custom(
     Key key = null,
     Axis scrollDirection                 = Axis.vertical,
     bool reverse                         = false,
     ScrollController controller          = null,
     bool?primary                         = null,
     ScrollPhysics physics                = null,
     bool shrinkWrap                      = false,
     EdgeInsets padding                   = null,
     float?itemExtent                     = null,
     SliverChildDelegate childrenDelegate = null,
     float?cacheExtent                    = null
     )
 {
     return(new ListView(
                key,
                scrollDirection,
                reverse,
                controller,
                primary,
                physics,
                shrinkWrap,
                padding,
                itemExtent,
                childrenDelegate,
                cacheExtent));
 }
 public static ListView seperated(
     Key key = null,
     Axis scrollDirection                  = Axis.vertical,
     bool reverse                          = false,
     ScrollController controller           = null,
     bool?primary                          = null,
     ScrollPhysics physics                 = null,
     bool shrinkWrap                       = false,
     EdgeInsets padding                    = null,
     IndexedWidgetBuilder itemBuilder      = null,
     IndexedWidgetBuilder separatorBuilder = null,
     int itemCount                         = 0,
     bool addAutomaticKeepAlives           = true,
     bool addRepaintBoundaries             = true,
     float?cacheExtent                     = null
     )
 {
     return(new ListView(
                key,
                scrollDirection,
                reverse,
                controller,
                primary,
                physics,
                shrinkWrap,
                padding,
                itemBuilder,
                separatorBuilder,
                itemCount,
                addAutomaticKeepAlives,
                addRepaintBoundaries,
                cacheExtent
                ));
 }
Exemple #18
0
 public override void initState()
 {
     base.initState();
     this.scrollController = this.widget.controller ?? new FixedExtentScrollController();
     if (this.widget.controller is FixedExtentScrollController controller)
     {
         this._lastReportedItemIndex = controller.initialItem;
     }
 }
 public PrimaryScrollController(
     Key key = null,
     ScrollController controller = null,
     Widget child = null
     ) : base(key: key, child: child)
 {
     D.assert(controller != null);
     this.controller = controller;
 }
Exemple #20
0
 public override void didUpdateWidget(StatefulWidget oldWidget)
 {
     base.didUpdateWidget(oldWidget: oldWidget);
     if (widget.controller != null && widget.controller != scrollController)
     {
         var oldScrollController = scrollController;
         SchedulerBinding.instance.addPostFrameCallback(_ => { oldScrollController.dispose(); });
         scrollController = widget.controller;
     }
 }
Exemple #21
0
 public override void didUpdateWidget(StatefulWidget oldWidget)
 {
     base.didUpdateWidget(oldWidget);
     if (this.widget.controller != null && this.widget.controller != this.scrollController)
     {
         ScrollController oldScrollController = this.scrollController;
         SchedulerBinding.instance.addPostFrameCallback((_) => { oldScrollController.dispose(); });
         this.scrollController = this.widget.controller;
     }
 }
Exemple #22
0
        public Scrollable(
            Key key = null,
            AxisDirection axisDirection     = AxisDirection.down,
            ScrollController controller     = null,
            ScrollPhysics physics           = null,
            ViewportBuilder viewportBuilder = null
            ) : base(key: key)
        {
            D.assert(viewportBuilder != null);

            this.axisDirection   = axisDirection;
            this.controller      = controller;
            this.physics         = physics;
            this.viewportBuilder = viewportBuilder;
        }
Exemple #23
0
 public ListWheelScrollView(
     float itemExtent,
     Key key = null,
     ScrollController controller = null,
     ScrollPhysics physics       = null,
     float diameterRatio         = RenderListWheelViewport.defaultDiameterRatio,
     float perspective           = RenderListWheelViewport.defaultPerspective,
     float offAxisFraction       = 0.0f,
     bool useMagnifier           = false,
     float magnification         = 1.0f,
     float squeeze = 1.0f,
     ValueChanged <int> onSelectedItemChanged = null,
     float overAndUnderCenterOpacity          = 1.0f,
     bool clipToSize = true,
     bool renderChildrenOutsideViewport   = false,
     ListWheelChildDelegate childDelegate = null
     ) : base(key: key)
 {
     D.assert(childDelegate != null);
     D.assert(diameterRatio > 0.0, () => RenderListWheelViewport.diameterRatioZeroMessage);
     D.assert(perspective > 0);
     D.assert(perspective <= 0.01, () => RenderListWheelViewport.perspectiveTooHighMessage);
     D.assert(magnification > 0);
     D.assert(overAndUnderCenterOpacity >= 0 && overAndUnderCenterOpacity <= 1);
     D.assert(itemExtent != null);
     D.assert(itemExtent > 0);
     D.assert(squeeze > 0);
     D.assert(
         !renderChildrenOutsideViewport || !clipToSize, () =>
         RenderListWheelViewport.clipToSizeAndRenderChildrenOutsideViewportConflict
         );
     this.controller                    = controller;
     this.physics                       = physics;
     this.diameterRatio                 = diameterRatio;
     this.perspective                   = perspective;
     this.offAxisFraction               = offAxisFraction;
     this.useMagnifier                  = useMagnifier;
     this.magnification                 = magnification;
     this.overAndUnderCenterOpacity     = overAndUnderCenterOpacity;
     this.itemExtent                    = itemExtent;
     this.squeeze                       = squeeze;
     this.onSelectedItemChanged         = onSelectedItemChanged;
     this.clipToSize                    = clipToSize;
     this.renderChildrenOutsideViewport = renderChildrenOutsideViewport;
     this.childDelegate                 = childDelegate;
 }
Exemple #24
0
 public _FixedExtentScrollable(
     float itemExtent,
     ViewportBuilder viewportBuilder,
     Key key = null,
     AxisDirection axisDirection = AxisDirection.down,
     ScrollController controller = null,
     ScrollPhysics physics       = null
     ) : base(
         key: key,
         axisDirection: axisDirection,
         controller: controller,
         physics: physics,
         viewportBuilder: viewportBuilder
         )
 {
     this.itemExtent = itemExtent;
 }
 ListView(
     Key key = null,
     Axis scrollDirection                  = Axis.vertical,
     bool reverse                          = false,
     ScrollController controller           = null,
     bool?primary                          = null,
     ScrollPhysics physics                 = null,
     bool shrinkWrap                       = false,
     EdgeInsets padding                    = null,
     IndexedWidgetBuilder itemBuilder      = null,
     IndexedWidgetBuilder separatorBuilder = null,
     int itemCount                         = 0,
     bool addAutomaticKeepAlives           = true,
     bool addRepaintBoundaries             = true,
     float?cacheExtent                     = null,
     DragStartBehavior dragStartBehavior   = DragStartBehavior.start
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         padding: padding,
         cacheExtent: cacheExtent,
         dragStartBehavior: dragStartBehavior
         )
 {
     D.assert(itemBuilder != null);
     D.assert(separatorBuilder != null);
     D.assert(itemCount >= 0);
     this.itemExtent       = null;
     this.childrenDelegate = new SliverChildBuilderDelegate(
         (context, index) => {
         int itemIndex = index / 2;
         return(index % 2 == 0
                 ? itemBuilder(context, itemIndex)
                 : separatorBuilder(context, itemIndex));
     },
         childCount: Mathf.Max(0, itemCount * 2 - 1),
         addAutomaticKeepAlives: addAutomaticKeepAlives,
         addRepaintBoundaries: addRepaintBoundaries
         );
 }
Exemple #26
0
        public override Widget build(BuildContext context)
        {
            List <Widget> slivers       = this.buildSlivers(context);
            AxisDirection axisDirection = this.getDirection(context);

            ScrollController scrollController = this.primary ? PrimaryScrollController.of(context) : this.controller;

            Scrollable scrollable = new Scrollable(
                axisDirection: axisDirection,
                controller: scrollController,
                physics: this.physics,
                viewportBuilder: (viewportContext, offset) =>
                this.buildViewport(viewportContext, offset, axisDirection, slivers)
                );

            return(this.primary && scrollController != null
                ? (Widget)PrimaryScrollController.none(child: scrollable)
                : scrollable);
        }
 public GridView(
     Key key = null,
     Axis scrollDirection                = Axis.vertical,
     bool reverse                        = false,
     ScrollController controller         = null,
     bool?primary                        = null,
     ScrollPhysics physics               = null,
     bool shrinkWrap                     = false,
     EdgeInsets padding                  = null,
     float?maxCrossAxisExtent            = null,
     float mainAxisSpacing               = 0.0f,
     float crossAxisSpacing              = 0.0f,
     float childAspectRatio              = 1.0f,
     bool addAutomaticKeepAlives         = true,
     bool addRepaintBoundaries           = true,
     bool addSemanticIndexes             = true,
     List <Widget> children              = null,
     DragStartBehavior dragStartBehavior = DragStartBehavior.start
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         padding: padding,
         dragStartBehavior: dragStartBehavior
         )
 {
     this.gridDelegate = new SliverGridDelegateWithMaxCrossAxisExtent(
         maxCrossAxisExtent: maxCrossAxisExtent ?? 0,
         mainAxisSpacing: mainAxisSpacing,
         crossAxisSpacing: crossAxisSpacing,
         childAspectRatio: childAspectRatio
         );
     this.childrenDelegate = new SliverChildListDelegate(
         children ?? new List <Widget> {
     },
         addAutomaticKeepAlives: addAutomaticKeepAlives,
         addRepaintBoundaries: addRepaintBoundaries
         );
 }
Exemple #28
0
        public Scrollable(
            Key key = null,
            AxisDirection?axisDirection     = AxisDirection.down,
            ScrollController controller     = null,
            ScrollPhysics physics           = null,
            ViewportBuilder viewportBuilder = null,
            ScrollIncrementCalculator incrementCalculator = null,
            DragStartBehavior dragStartBehavior           = DragStartBehavior.start
            ) : base(key: key)
        {
            D.assert(axisDirection != null);
            D.assert(viewportBuilder != null);

            this.axisDirection       = axisDirection.Value;
            this.controller          = controller;
            this.physics             = physics;
            this.viewportBuilder     = viewportBuilder;
            this.incrementCalculator = incrementCalculator;
            this.dragStartBehavior   = dragStartBehavior;
        }
Exemple #29
0
 public GridView(
     Key key = null,
     Axis scrollDirection        = Axis.vertical,
     bool reverse                = false,
     ScrollController controller = null,
     bool?primary                = null,
     ScrollPhysics physics       = null,
     bool shrinkWrap             = false,
     EdgeInsets padding          = null,
     int?crossAxisCount          = null,
     float mainAxisSpacing       = 0.0f,
     float crossAxisSpacing      = 0.0f,
     float childAspectRatio      = 1.0f,
     bool addAutomaticKeepAlives = true,
     bool addRepaintBoundaries   = true,
     float?cacheExtent           = null,
     List <Widget> children      = null
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         padding: padding,
         cacheExtent: cacheExtent
         )
 {
     this.gridDelegate = new SliverGridDelegateWithFixedCrossAxisCount(
         crossAxisCount: crossAxisCount ?? 0,
         mainAxisSpacing: mainAxisSpacing,
         crossAxisSpacing: crossAxisSpacing,
         childAspectRatio: childAspectRatio
         );
     this.childrenDelegate = new SliverChildListDelegate(
         children ?? new List <Widget>(),
         addAutomaticKeepAlives: addAutomaticKeepAlives,
         addRepaintBoundaries: addRepaintBoundaries
         );
 }
Exemple #30
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);
            }
        }