ScrollDragController constructor

ScrollDragController(
  1. {required ScrollActivityDelegate delegate,
  2. required DragStartDetails details,
  3. VoidCallback? onDragCanceled,
  4. double? carriedVelocity,
  5. double? motionStartDistanceThreshold}
)

Creates an object that scrolls a scroll view as the user drags their finger across the screen.

Implementation

ScrollDragController({
  required ScrollActivityDelegate delegate,
  required DragStartDetails details,
  this.onDragCanceled,
  this.carriedVelocity,
  this.motionStartDistanceThreshold,
}) : assert(
       motionStartDistanceThreshold == null || motionStartDistanceThreshold > 0.0,
       'motionStartDistanceThreshold must be a positive number or null',
     ),
     _delegate = delegate,
     _lastDetails = details,
     _retainMomentum = carriedVelocity != null && carriedVelocity != 0.0,
     _lastNonStationaryTimestamp = details.sourceTimeStamp,
     _kind = details.kind,
     _offsetSinceLastStop = motionStartDistanceThreshold == null ? null : 0.0 {
  // TODO(polina-c): stop duplicating code across disposables
  // https://github.com/flutter/flutter/issues/137435
  if (kFlutterMemoryAllocationsEnabled) {
    FlutterMemoryAllocations.instance.dispatchObjectCreated(
      library: 'package:flutter/widgets.dart',
      className: '$ScrollDragController',
      object: this,
    );
  }
}