@@ -294,7 +294,7 @@ class CustomPointerScrollable extends StatefulWidget {
294
294
_CustomPointerScrollableState ? scrollable =
295
295
CustomPointerScrollable .of (context);
296
296
while (scrollable != null ) {
297
- futures.add (scrollable.position! .ensureVisible (
297
+ futures.add (scrollable.position.ensureVisible (
298
298
context.findRenderObject ()! ,
299
299
alignment: alignment,
300
300
duration: duration,
@@ -326,7 +326,7 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
326
326
/// To control what kind of [ScrollPosition] is created for a [Scrollable] ,
327
327
/// provide it with custom [ScrollController] that creates the appropriate
328
328
/// [ScrollPosition] in its [ScrollController.createScrollPosition] method.
329
- ScrollPosition ? get position => _position;
329
+ ScrollPosition get position => _position! ;
330
330
ScrollPosition ? _position;
331
331
332
332
@override
@@ -354,8 +354,7 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
354
354
controller? .createScrollPosition (_physics! , this , oldPosition) ??
355
355
ScrollPositionWithSingleContext (
356
356
physics: _physics! , context: this , oldPosition: oldPosition);
357
- assert (position != null );
358
- controller? .attach (position! );
357
+ controller? .attach (position);
359
358
}
360
359
361
360
@override
@@ -387,17 +386,17 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
387
386
super .didUpdateWidget (oldWidget);
388
387
389
388
if (widget.controller != oldWidget.controller) {
390
- oldWidget.controller? .detach (position! );
391
- widget.controller? .attach (position! );
389
+ oldWidget.controller? .detach (position);
390
+ widget.controller? .attach (position);
392
391
}
393
392
394
393
if (_shouldUpdatePosition (oldWidget)) _updatePosition ();
395
394
}
396
395
397
396
@override
398
397
void dispose () {
399
- widget.controller? .detach (position! );
400
- position! .dispose ();
398
+ widget.controller? .detach (position);
399
+ position.dispose ();
401
400
super .dispose ();
402
401
}
403
402
@@ -516,15 +515,15 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
516
515
void _handleDragDown (DragDownDetails details) {
517
516
assert (_drag == null );
518
517
assert (_hold == null );
519
- _hold = position! .hold (_disposeHold);
518
+ _hold = position.hold (_disposeHold);
520
519
}
521
520
522
521
void _handleDragStart (DragStartDetails details) {
523
522
// It's possible for _hold to become null between _handleDragDown and
524
523
// _handleDragStart, for example if some user code calls jumpTo or otherwise
525
524
// triggers a new activity to begin.
526
525
assert (_drag == null );
527
- _drag = position! .drag (details, _disposeDrag);
526
+ _drag = position.drag (details, _disposeDrag);
528
527
assert (_drag != null );
529
528
assert (_hold == null );
530
529
}
@@ -573,17 +572,16 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
573
572
delta *= - 1 ;
574
573
}
575
574
576
- return math.min (
577
- math.max (position! .pixels + delta, position! .minScrollExtent),
578
- position! .maxScrollExtent);
575
+ return math.min (math.max (position.pixels + delta, position.minScrollExtent),
576
+ position.maxScrollExtent);
579
577
}
580
578
581
579
void _receivedPointerSignal (PointerSignalEvent event) {
582
- if (event is PointerScrollEvent && position != null ) {
580
+ if (event is PointerScrollEvent ) {
583
581
final double targetScrollOffset =
584
582
_targetScrollOffsetForPointerScroll (event);
585
583
// Only express interest in the event if it would actually result in a scroll.
586
- if (targetScrollOffset != position! .pixels) {
584
+ if (targetScrollOffset != position.pixels) {
587
585
GestureBinding .instance! .pointerSignalResolver
588
586
.register (event, _handlePointerScroll);
589
587
}
@@ -592,13 +590,13 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
592
590
593
591
void _handlePointerScroll (PointerEvent event) {
594
592
assert (event is PointerScrollEvent );
595
- if (_physics != null && ! _physics! .shouldAcceptUserOffset (position! )) {
593
+ if (_physics != null && ! _physics! .shouldAcceptUserOffset (position)) {
596
594
return ;
597
595
}
598
596
final double targetScrollOffset =
599
597
_targetScrollOffsetForPointerScroll (event as PointerScrollEvent );
600
- if (targetScrollOffset != position! .pixels) {
601
- position! .jumpTo (targetScrollOffset);
598
+ if (targetScrollOffset != position.pixels) {
599
+ position.jumpTo (targetScrollOffset);
602
600
}
603
601
}
604
602
@@ -618,7 +616,7 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
618
616
// must be placed above the widget using it: RawGestureDetector
619
617
Widget result = _ScrollableScope (
620
618
scrollable: this ,
621
- position: position! ,
619
+ position: position,
622
620
// TODO(ianh): Having all these global keys is sad.
623
621
child: Listener (
624
622
onPointerSignal:
@@ -634,7 +632,7 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
634
632
key: _ignorePointerKey,
635
633
ignoring: _shouldIgnorePointer,
636
634
ignoringSemantics: false ,
637
- child: widget.viewportBuilder (context, position! ),
635
+ child: widget.viewportBuilder (context, position),
638
636
),
639
637
),
640
638
),
@@ -645,7 +643,7 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
645
643
result = _ScrollSemantics (
646
644
key: _scrollSemanticsKey,
647
645
child: result,
648
- position: position! ,
646
+ position: position,
649
647
allowImplicitScrolling: widget.physics? .allowImplicitScrolling ??
650
648
_physics! .allowImplicitScrolling,
651
649
semanticChildCount: widget.semanticChildCount,
0 commit comments