Skip to content

Commit 07e23b8

Browse files
committed
Update custom_pointer_scroll_view.dart
1 parent 8786f77 commit 07e23b8

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

packages/devtools_app/lib/src/primitives/custom_pointer_scroll_view.dart

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class CustomPointerScrollable extends StatefulWidget {
294294
_CustomPointerScrollableState? scrollable =
295295
CustomPointerScrollable.of(context);
296296
while (scrollable != null) {
297-
futures.add(scrollable.position!.ensureVisible(
297+
futures.add(scrollable.position.ensureVisible(
298298
context.findRenderObject()!,
299299
alignment: alignment,
300300
duration: duration,
@@ -326,7 +326,7 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
326326
/// To control what kind of [ScrollPosition] is created for a [Scrollable],
327327
/// provide it with custom [ScrollController] that creates the appropriate
328328
/// [ScrollPosition] in its [ScrollController.createScrollPosition] method.
329-
ScrollPosition? get position => _position;
329+
ScrollPosition get position => _position!;
330330
ScrollPosition? _position;
331331

332332
@override
@@ -354,8 +354,7 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
354354
controller?.createScrollPosition(_physics!, this, oldPosition) ??
355355
ScrollPositionWithSingleContext(
356356
physics: _physics!, context: this, oldPosition: oldPosition);
357-
assert(position != null);
358-
controller?.attach(position!);
357+
controller?.attach(position);
359358
}
360359

361360
@override
@@ -387,17 +386,17 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
387386
super.didUpdateWidget(oldWidget);
388387

389388
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);
392391
}
393392

394393
if (_shouldUpdatePosition(oldWidget)) _updatePosition();
395394
}
396395

397396
@override
398397
void dispose() {
399-
widget.controller?.detach(position!);
400-
position!.dispose();
398+
widget.controller?.detach(position);
399+
position.dispose();
401400
super.dispose();
402401
}
403402

@@ -516,15 +515,15 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
516515
void _handleDragDown(DragDownDetails details) {
517516
assert(_drag == null);
518517
assert(_hold == null);
519-
_hold = position!.hold(_disposeHold);
518+
_hold = position.hold(_disposeHold);
520519
}
521520

522521
void _handleDragStart(DragStartDetails details) {
523522
// It's possible for _hold to become null between _handleDragDown and
524523
// _handleDragStart, for example if some user code calls jumpTo or otherwise
525524
// triggers a new activity to begin.
526525
assert(_drag == null);
527-
_drag = position!.drag(details, _disposeDrag);
526+
_drag = position.drag(details, _disposeDrag);
528527
assert(_drag != null);
529528
assert(_hold == null);
530529
}
@@ -573,17 +572,16 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
573572
delta *= -1;
574573
}
575574

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);
579577
}
580578

581579
void _receivedPointerSignal(PointerSignalEvent event) {
582-
if (event is PointerScrollEvent && position != null) {
580+
if (event is PointerScrollEvent) {
583581
final double targetScrollOffset =
584582
_targetScrollOffsetForPointerScroll(event);
585583
// Only express interest in the event if it would actually result in a scroll.
586-
if (targetScrollOffset != position!.pixels) {
584+
if (targetScrollOffset != position.pixels) {
587585
GestureBinding.instance!.pointerSignalResolver
588586
.register(event, _handlePointerScroll);
589587
}
@@ -592,13 +590,13 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
592590

593591
void _handlePointerScroll(PointerEvent event) {
594592
assert(event is PointerScrollEvent);
595-
if (_physics != null && !_physics!.shouldAcceptUserOffset(position!)) {
593+
if (_physics != null && !_physics!.shouldAcceptUserOffset(position)) {
596594
return;
597595
}
598596
final double targetScrollOffset =
599597
_targetScrollOffsetForPointerScroll(event as PointerScrollEvent);
600-
if (targetScrollOffset != position!.pixels) {
601-
position!.jumpTo(targetScrollOffset);
598+
if (targetScrollOffset != position.pixels) {
599+
position.jumpTo(targetScrollOffset);
602600
}
603601
}
604602

@@ -618,7 +616,7 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
618616
// must be placed above the widget using it: RawGestureDetector
619617
Widget result = _ScrollableScope(
620618
scrollable: this,
621-
position: position!,
619+
position: position,
622620
// TODO(ianh): Having all these global keys is sad.
623621
child: Listener(
624622
onPointerSignal:
@@ -634,7 +632,7 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
634632
key: _ignorePointerKey,
635633
ignoring: _shouldIgnorePointer,
636634
ignoringSemantics: false,
637-
child: widget.viewportBuilder(context, position!),
635+
child: widget.viewportBuilder(context, position),
638636
),
639637
),
640638
),
@@ -645,7 +643,7 @@ class _CustomPointerScrollableState extends State<CustomPointerScrollable>
645643
result = _ScrollSemantics(
646644
key: _scrollSemanticsKey,
647645
child: result,
648-
position: position!,
646+
position: position,
649647
allowImplicitScrolling: widget.physics?.allowImplicitScrolling ??
650648
_physics!.allowImplicitScrolling,
651649
semanticChildCount: widget.semanticChildCount,

0 commit comments

Comments
 (0)