Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
224e6aa1
Unverified
Commit
224e6aa1
authored
Jan 23, 2023
by
Michael Goderbauer
Committed by
GitHub
Jan 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unnecessary null checks in flutter/gestures (#118926)
parent
90ffb1c6
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
52 additions
and
159 deletions
+52
-159
arena.dart
packages/flutter/lib/src/gestures/arena.dart
+0
-1
binding.dart
packages/flutter/lib/src/gestures/binding.dart
+0
-4
converter.dart
packages/flutter/lib/src/gestures/converter.dart
+0
-2
drag_details.dart
packages/flutter/lib/src/gestures/drag_details.dart
+4
-8
events.dart
packages/flutter/lib/src/gestures/events.dart
+21
-70
force_press.dart
packages/flutter/lib/src/gestures/force_press.dart
+2
-7
hit_test.dart
packages/flutter/lib/src/gestures/hit_test.dart
+0
-2
long_press.dart
packages/flutter/lib/src/gestures/long_press.dart
+4
-9
monodrag.dart
packages/flutter/lib/src/gestures/monodrag.dart
+1
-3
multidrag.dart
packages/flutter/lib/src/gestures/multidrag.dart
+3
-13
multitap.dart
packages/flutter/lib/src/gestures/multitap.dart
+3
-8
pointer_signal_resolver.dart
...ges/flutter/lib/src/gestures/pointer_signal_resolver.dart
+0
-2
recognizer.dart
packages/flutter/lib/src/gestures/recognizer.dart
+0
-1
scale.dart
packages/flutter/lib/src/gestures/scale.dart
+7
-14
tap.dart
packages/flutter/lib/src/gestures/tap.dart
+2
-5
velocity_tracker.dart
packages/flutter/lib/src/gestures/velocity_tracker.dart
+5
-10
No files found.
packages/flutter/lib/src/gestures/arena.dart
View file @
224e6aa1
...
...
@@ -266,7 +266,6 @@ class GestureArenaManager {
void
_resolveInFavorOf
(
int
pointer
,
_GestureArena
state
,
GestureArenaMember
member
)
{
assert
(
state
==
_arenas
[
pointer
]);
assert
(
state
!=
null
);
assert
(
state
.
eagerWinner
==
null
||
state
.
eagerWinner
==
member
);
assert
(!
state
.
isOpen
);
_arenas
.
remove
(
pointer
);
...
...
packages/flutter/lib/src/gestures/binding.dart
View file @
224e6aa1
...
...
@@ -83,8 +83,6 @@ class _Resampler {
// Add `event` for resampling or dispatch it directly if
// not a touch event.
void
addOrDispatch
(
PointerEvent
event
)
{
final
SchedulerBinding
scheduler
=
SchedulerBinding
.
instance
;
assert
(
scheduler
!=
null
);
// Add touch event to resampler or dispatch pointer event directly.
if
(
event
.
kind
==
PointerDeviceKind
.
touch
)
{
// Save last event time for debugPrint of resampling margin.
...
...
@@ -108,7 +106,6 @@ class _Resampler {
// The `samplingClock` is the clock used to determine frame time age.
void
sample
(
Duration
samplingOffset
,
SamplingClock
clock
)
{
final
SchedulerBinding
scheduler
=
SchedulerBinding
.
instance
;
assert
(
scheduler
!=
null
);
// Initialize `_frameTime` if needed. This will be used for periodic
// sampling when frame callbacks are not received.
...
...
@@ -391,7 +388,6 @@ mixin GestureBinding on BindingBase implements HitTestable, HitTestDispatcher, H
if
(
hitTestResult
!=
null
||
event
is
PointerAddedEvent
||
event
is
PointerRemovedEvent
)
{
assert
(
event
.
position
!=
null
);
dispatchEvent
(
event
,
hitTestResult
);
}
}
...
...
packages/flutter/lib/src/gestures/converter.dart
View file @
224e6aa1
...
...
@@ -54,7 +54,6 @@ class PointerEventConverter {
.
where
((
ui
.
PointerData
datum
)
=>
datum
.
signalKind
!=
ui
.
PointerSignalKind
.
unknown
)
.
map
((
ui
.
PointerData
datum
)
{
final
Offset
position
=
Offset
(
datum
.
physicalX
,
datum
.
physicalY
)
/
devicePixelRatio
;
assert
(
position
!=
null
);
final
Offset
delta
=
Offset
(
datum
.
physicalDeltaX
,
datum
.
physicalDeltaY
)
/
devicePixelRatio
;
final
double
radiusMinor
=
_toLogicalPixels
(
datum
.
radiusMinor
,
devicePixelRatio
);
final
double
radiusMajor
=
_toLogicalPixels
(
datum
.
radiusMajor
,
devicePixelRatio
);
...
...
@@ -62,7 +61,6 @@ class PointerEventConverter {
final
double
radiusMax
=
_toLogicalPixels
(
datum
.
radiusMax
,
devicePixelRatio
);
final
Duration
timeStamp
=
datum
.
timeStamp
;
final
PointerDeviceKind
kind
=
datum
.
kind
;
assert
(
datum
.
change
!=
null
);
switch
(
datum
.
signalKind
??
ui
.
PointerSignalKind
.
none
)
{
case
ui
.
PointerSignalKind
.
none
:
switch
(
datum
.
change
)
{
...
...
packages/flutter/lib/src/gestures/drag_details.dart
View file @
224e6aa1
...
...
@@ -25,8 +25,7 @@ class DragDownDetails {
DragDownDetails
({
this
.
globalPosition
=
Offset
.
zero
,
Offset
?
localPosition
,
})
:
assert
(
globalPosition
!=
null
),
localPosition
=
localPosition
??
globalPosition
;
})
:
localPosition
=
localPosition
??
globalPosition
;
/// The global position at which the pointer contacted the screen.
///
...
...
@@ -73,8 +72,7 @@ class DragStartDetails {
this
.
globalPosition
=
Offset
.
zero
,
Offset
?
localPosition
,
this
.
kind
,
})
:
assert
(
globalPosition
!=
null
),
localPosition
=
localPosition
??
globalPosition
;
})
:
localPosition
=
localPosition
??
globalPosition
;
/// Recorded timestamp of the source pointer event that triggered the drag
/// event.
...
...
@@ -142,8 +140,7 @@ class DragUpdateDetails {
this
.
primaryDelta
,
required
this
.
globalPosition
,
Offset
?
localPosition
,
})
:
assert
(
delta
!=
null
),
assert
(
})
:
assert
(
primaryDelta
==
null
||
(
primaryDelta
==
delta
.
dx
&&
delta
.
dy
==
0.0
)
||
(
primaryDelta
==
delta
.
dy
&&
delta
.
dx
==
0.0
),
...
...
@@ -223,8 +220,7 @@ class DragEndDetails {
DragEndDetails
({
this
.
velocity
=
Velocity
.
zero
,
this
.
primaryVelocity
,
})
:
assert
(
velocity
!=
null
),
assert
(
})
:
assert
(
primaryVelocity
==
null
||
primaryVelocity
==
velocity
.
pixelsPerSecond
.
dx
||
primaryVelocity
==
velocity
.
pixelsPerSecond
.
dy
,
...
...
packages/flutter/lib/src/gestures/events.dart
View file @
224e6aa1
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/gestures/force_press.dart
View file @
224e6aa1
...
...
@@ -52,9 +52,7 @@ class ForcePressDetails {
required
this
.
globalPosition
,
Offset
?
localPosition
,
required
this
.
pressure
,
})
:
assert
(
globalPosition
!=
null
),
assert
(
pressure
!=
null
),
localPosition
=
localPosition
??
globalPosition
;
})
:
localPosition
=
localPosition
??
globalPosition
;
/// The global position at which the function was called.
final
Offset
globalPosition
;
...
...
@@ -134,10 +132,7 @@ class ForcePressGestureRecognizer extends OneSequenceGestureRecognizer {
super
.
kind
,
super
.
supportedDevices
,
super
.
allowedButtonsFilter
,
})
:
assert
(
startPressure
!=
null
),
assert
(
peakPressure
!=
null
),
assert
(
interpolation
!=
null
),
assert
(
peakPressure
>
startPressure
);
})
:
assert
(
peakPressure
>
startPressure
);
/// A pointer is in contact with the screen and has just pressed with a force
/// exceeding the [startPressure]. Consequently, if there were other gesture
...
...
packages/flutter/lib/src/gestures/hit_test.dart
View file @
224e6aa1
...
...
@@ -215,7 +215,6 @@ class HitTestResult {
/// around this function for hit testing on [RenderBox]s.
@protected
void
pushTransform
(
Matrix4
transform
)
{
assert
(
transform
!=
null
);
assert
(
_debugVectorMoreOrLessEquals
(
transform
.
getRow
(
2
),
Vector4
(
0
,
0
,
1
,
0
))
&&
_debugVectorMoreOrLessEquals
(
transform
.
getColumn
(
2
),
Vector4
(
0
,
0
,
1
,
0
)),
...
...
@@ -255,7 +254,6 @@ class HitTestResult {
/// around this function for hit testing on [RenderSliver]s.
@protected
void
pushOffset
(
Offset
offset
)
{
assert
(
offset
!=
null
);
_localTransforms
.
add
(
_OffsetTransformPart
(
offset
));
}
...
...
packages/flutter/lib/src/gestures/long_press.dart
View file @
224e6aa1
...
...
@@ -115,8 +115,7 @@ class LongPressDownDetails {
this
.
globalPosition
=
Offset
.
zero
,
Offset
?
localPosition
,
this
.
kind
,
})
:
assert
(
globalPosition
!=
null
),
localPosition
=
localPosition
??
globalPosition
;
})
:
localPosition
=
localPosition
??
globalPosition
;
/// The global position at which the pointer contacted the screen.
final
Offset
globalPosition
;
...
...
@@ -142,8 +141,7 @@ class LongPressStartDetails {
const
LongPressStartDetails
({
this
.
globalPosition
=
Offset
.
zero
,
Offset
?
localPosition
,
})
:
assert
(
globalPosition
!=
null
),
localPosition
=
localPosition
??
globalPosition
;
})
:
localPosition
=
localPosition
??
globalPosition
;
/// The global position at which the pointer initially contacted the screen.
final
Offset
globalPosition
;
...
...
@@ -168,9 +166,7 @@ class LongPressMoveUpdateDetails {
Offset
?
localPosition
,
this
.
offsetFromOrigin
=
Offset
.
zero
,
Offset
?
localOffsetFromOrigin
,
})
:
assert
(
globalPosition
!=
null
),
assert
(
offsetFromOrigin
!=
null
),
localPosition
=
localPosition
??
globalPosition
,
})
:
localPosition
=
localPosition
??
globalPosition
,
localOffsetFromOrigin
=
localOffsetFromOrigin
??
offsetFromOrigin
;
/// The global position of the pointer when it triggered this update.
...
...
@@ -205,8 +201,7 @@ class LongPressEndDetails {
this
.
globalPosition
=
Offset
.
zero
,
Offset
?
localPosition
,
this
.
velocity
=
Velocity
.
zero
,
})
:
assert
(
globalPosition
!=
null
),
localPosition
=
localPosition
??
globalPosition
;
})
:
localPosition
=
localPosition
??
globalPosition
;
/// The global position at which the pointer lifted from the screen.
final
Offset
globalPosition
;
...
...
packages/flutter/lib/src/gestures/monodrag.dart
View file @
224e6aa1
...
...
@@ -84,7 +84,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
this
.
velocityTrackerBuilder
=
_defaultBuilder
,
super
.
supportedDevices
,
super
.
allowedButtonsFilter
=
_defaultButtonAcceptBehavior
,
})
:
assert
(
dragStartBehavior
!=
null
)
;
});
static
VelocityTracker
_defaultBuilder
(
PointerEvent
event
)
=>
VelocityTracker
.
withKind
(
event
.
kind
);
...
...
@@ -313,7 +313,6 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
event
is
PointerPanZoomStartEvent
||
event
is
PointerPanZoomUpdateEvent
))
{
final
VelocityTracker
tracker
=
_velocityTrackers
[
event
.
pointer
]!;
assert
(
tracker
!=
null
);
if
(
event
is
PointerPanZoomStartEvent
)
{
tracker
.
addPosition
(
event
.
timeStamp
,
Offset
.
zero
);
}
else
if
(
event
is
PointerPanZoomUpdateEvent
)
{
...
...
@@ -492,7 +491,6 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
}
final
VelocityTracker
tracker
=
_velocityTrackers
[
pointer
]!;
assert
(
tracker
!=
null
);
final
DragEndDetails
details
;
final
String
Function
()
debugReport
;
...
...
packages/flutter/lib/src/gestures/multidrag.dart
View file @
224e6aa1
...
...
@@ -35,8 +35,7 @@ abstract class MultiDragPointerState {
///
/// The [initialPosition] argument must not be null.
MultiDragPointerState
(
this
.
initialPosition
,
this
.
kind
,
this
.
gestureSettings
)
:
assert
(
initialPosition
!=
null
),
_velocityTracker
=
VelocityTracker
.
withKind
(
kind
);
:
_velocityTracker
=
VelocityTracker
.
withKind
(
kind
);
/// Device specific gesture configuration that should be preferred over
/// framework constants.
...
...
@@ -133,7 +132,6 @@ abstract class MultiDragPointerState {
void
_startDrag
(
Drag
client
)
{
assert
(
_arenaEntry
!=
null
);
assert
(
_client
==
null
);
assert
(
client
!=
null
);
assert
(
pendingDelta
!=
null
);
_client
=
client
;
final
DragUpdateDetails
details
=
DragUpdateDetails
(
...
...
@@ -240,8 +238,6 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer {
@override
void
addAllowedPointer
(
PointerDownEvent
event
)
{
assert
(
_pointers
!=
null
);
assert
(
event
.
pointer
!=
null
);
assert
(
event
.
position
!=
null
);
assert
(!
_pointers
!.
containsKey
(
event
.
pointer
));
final
MultiDragPointerState
state
=
createNewPointerState
(
event
);
_pointers
![
event
.
pointer
]
=
state
;
...
...
@@ -257,9 +253,6 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer {
void
_handleEvent
(
PointerEvent
event
)
{
assert
(
_pointers
!=
null
);
assert
(
event
.
pointer
!=
null
);
assert
(
event
.
timeStamp
!=
null
);
assert
(
event
.
position
!=
null
);
assert
(
_pointers
!.
containsKey
(
event
.
pointer
));
final
MultiDragPointerState
state
=
_pointers
![
event
.
pointer
]!;
if
(
event
is
PointerMoveEvent
)
{
...
...
@@ -296,7 +289,6 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer {
Drag
?
_startDrag
(
Offset
initialPosition
,
int
pointer
)
{
assert
(
_pointers
!=
null
);
final
MultiDragPointerState
state
=
_pointers
![
pointer
]!;
assert
(
state
!=
null
);
assert
(
state
.
_pendingDelta
!=
null
);
Drag
?
drag
;
if
(
onStart
!=
null
)
{
...
...
@@ -315,7 +307,6 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer {
assert
(
_pointers
!=
null
);
if
(
_pointers
!.
containsKey
(
pointer
))
{
final
MultiDragPointerState
state
=
_pointers
![
pointer
]!;
assert
(
state
!=
null
);
state
.
rejected
();
_removeState
(
pointer
);
}
// else we already preemptively forgot about it (e.g. we got an up event)
...
...
@@ -515,8 +506,7 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer {
}
class
_DelayedPointerState
extends
MultiDragPointerState
{
_DelayedPointerState
(
super
.
initialPosition
,
Duration
delay
,
super
.
kind
,
super
.
deviceGestureSettings
)
:
assert
(
delay
!=
null
)
{
_DelayedPointerState
(
super
.
initialPosition
,
Duration
delay
,
super
.
kind
,
super
.
deviceGestureSettings
)
{
_timer
=
Timer
(
delay
,
_delayPassed
);
}
...
...
@@ -614,7 +604,7 @@ class DelayedMultiDragGestureRecognizer extends MultiDragGestureRecognizer {
super
.
kind
,
super
.
supportedDevices
,
super
.
allowedButtonsFilter
,
})
:
assert
(
delay
!=
null
)
;
});
/// The amount of time the pointer must remain in the same place for the drag
/// to be recognized.
...
...
packages/flutter/lib/src/gestures/multitap.dart
View file @
224e6aa1
...
...
@@ -43,8 +43,7 @@ typedef GestureMultiTapCancelCallback = void Function(int pointer);
/// CountdownZoned tracks whether the specified duration has elapsed since
/// creation, honoring [Zone].
class
_CountdownZoned
{
_CountdownZoned
({
required
Duration
duration
})
:
assert
(
duration
!=
null
)
{
_CountdownZoned
({
required
Duration
duration
})
{
Timer
(
duration
,
_onTimeout
);
}
...
...
@@ -65,10 +64,7 @@ class _TapTracker {
required
this
.
entry
,
required
Duration
doubleTapMinTime
,
required
this
.
gestureSettings
,
})
:
assert
(
doubleTapMinTime
!=
null
),
assert
(
event
!=
null
),
assert
(
event
.
buttons
!=
null
),
pointer
=
event
.
pointer
,
})
:
pointer
=
event
.
pointer
,
_initialGlobalPosition
=
event
.
position
,
initialButtons
=
event
.
buttons
,
_doubleTapMinTimeCountdown
=
_CountdownZoned
(
duration:
doubleTapMinTime
);
...
...
@@ -684,8 +680,7 @@ class SerialTapCancelDetails {
/// The `count` argument must be greater than zero.
SerialTapCancelDetails
({
this
.
count
=
1
,
})
:
assert
(
count
!=
null
),
assert
(
count
>
0
);
})
:
assert
(
count
>
0
);
/// The number of consecutive taps that were in progress when the gesture was
/// interrupted.
...
...
packages/flutter/lib/src/gestures/pointer_signal_resolver.dart
View file @
224e6aa1
...
...
@@ -64,8 +64,6 @@ class PointerSignalResolver {
/// See the documentation for the [PointerSignalResolver] class on when and
/// how this method should be used.
void
register
(
PointerSignalEvent
event
,
PointerSignalResolvedCallback
callback
)
{
assert
(
event
!=
null
);
assert
(
callback
!=
null
);
assert
(
_currentEvent
==
null
||
_isSameEvent
(
_currentEvent
!,
event
));
if
(
_firstRegisteredCallback
!=
null
)
{
return
;
...
...
packages/flutter/lib/src/gestures/recognizer.dart
View file @
224e6aa1
...
...
@@ -267,7 +267,6 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT
@protected
@pragma
(
'vm:notify-debugger-on-exception'
)
T
?
invokeCallback
<
T
>(
String
name
,
RecognizerCallback
<
T
>
callback
,
{
String
Function
()?
debugReport
})
{
assert
(
callback
!=
null
);
T
?
result
;
try
{
assert
(()
{
...
...
packages/flutter/lib/src/gestures/scale.dart
View file @
224e6aa1
...
...
@@ -102,7 +102,7 @@ class ScaleStartDetails {
this
.
focalPoint
=
Offset
.
zero
,
Offset
?
localFocalPoint
,
this
.
pointerCount
=
0
,
})
:
assert
(
focalPoint
!=
null
),
localFocalPoint
=
localFocalPoint
??
focalPoint
;
})
:
localFocalPoint
=
localFocalPoint
??
focalPoint
;
/// The initial focal point of the pointers in contact with the screen.
///
...
...
@@ -151,12 +151,9 @@ class ScaleUpdateDetails {
this
.
rotation
=
0.0
,
this
.
pointerCount
=
0
,
this
.
focalPointDelta
=
Offset
.
zero
,
})
:
assert
(
focalPoint
!=
null
),
assert
(
focalPointDelta
!=
null
),
assert
(
scale
!=
null
&&
scale
>=
0.0
),
assert
(
horizontalScale
!=
null
&&
horizontalScale
>=
0.0
),
assert
(
verticalScale
!=
null
&&
verticalScale
>=
0.0
),
assert
(
rotation
!=
null
),
})
:
assert
(
scale
>=
0.0
),
assert
(
horizontalScale
>=
0.0
),
assert
(
verticalScale
>=
0.0
),
localFocalPoint
=
localFocalPoint
??
focalPoint
;
/// The amount the gesture's focal point has moved in the coordinate space of
...
...
@@ -248,8 +245,7 @@ class ScaleEndDetails {
/// Creates details for [GestureScaleEndCallback].
///
/// The [velocity] argument must not be null.
ScaleEndDetails
({
this
.
velocity
=
Velocity
.
zero
,
this
.
scaleVelocity
=
0
,
this
.
pointerCount
=
0
})
:
assert
(
velocity
!=
null
);
ScaleEndDetails
({
this
.
velocity
=
Velocity
.
zero
,
this
.
scaleVelocity
=
0
,
this
.
pointerCount
=
0
});
/// The velocity of the last pointer to be lifted off of the screen.
final
Velocity
velocity
;
...
...
@@ -279,7 +275,6 @@ typedef GestureScaleUpdateCallback = void Function(ScaleUpdateDetails details);
typedef
GestureScaleEndCallback
=
void
Function
(
ScaleEndDetails
details
);
bool
_isFlingGesture
(
Velocity
velocity
)
{
assert
(
velocity
!=
null
);
final
double
speedSquared
=
velocity
.
pixelsPerSecond
.
distanceSquared
;
return
speedSquared
>
kMinFlingVelocity
*
kMinFlingVelocity
;
}
...
...
@@ -299,9 +294,7 @@ class _LineBetweenPointers {
this
.
pointerStartId
=
0
,
this
.
pointerEndLocation
=
Offset
.
zero
,
this
.
pointerEndId
=
1
,
})
:
assert
(
pointerStartLocation
!=
null
&&
pointerEndLocation
!=
null
),
assert
(
pointerStartId
!=
null
&&
pointerEndId
!=
null
),
assert
(
pointerStartId
!=
pointerEndId
);
})
:
assert
(
pointerStartId
!=
pointerEndId
);
// The location and the id of the pointer that marks the start of the line.
final
Offset
pointerStartLocation
;
...
...
@@ -338,7 +331,7 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
this
.
dragStartBehavior
=
DragStartBehavior
.
down
,
this
.
trackpadScrollCausesScale
=
false
,
this
.
trackpadScrollToScaleFactor
=
kDefaultTrackpadScrollToScaleFactor
,
})
:
assert
(
dragStartBehavior
!=
null
)
;
});
/// Determines what point is used as the starting point in all calculations
/// involving this gesture.
...
...
packages/flutter/lib/src/gestures/tap.dart
View file @
224e6aa1
...
...
@@ -32,8 +32,7 @@ class TapDownDetails {
this
.
globalPosition
=
Offset
.
zero
,
Offset
?
localPosition
,
this
.
kind
,
})
:
assert
(
globalPosition
!=
null
),
localPosition
=
localPosition
??
globalPosition
;
})
:
localPosition
=
localPosition
??
globalPosition
;
/// The global position at which the pointer contacted the screen.
final
Offset
globalPosition
;
...
...
@@ -71,8 +70,7 @@ class TapUpDetails {
required
this
.
kind
,
this
.
globalPosition
=
Offset
.
zero
,
Offset
?
localPosition
,
})
:
assert
(
globalPosition
!=
null
),
localPosition
=
localPosition
??
globalPosition
;
})
:
localPosition
=
localPosition
??
globalPosition
;
/// The global position at which the pointer contacted the screen.
final
Offset
globalPosition
;
...
...
@@ -206,7 +204,6 @@ abstract class BaseTapGestureRecognizer extends PrimaryPointerGestureRecognizer
@override
void
addAllowedPointer
(
PointerDownEvent
event
)
{
assert
(
event
!=
null
);
if
(
state
==
GestureRecognizerState
.
ready
)
{
// If there is no result in the previous gesture arena,
// we ignore them and prepare to accept a new pointer.
...
...
packages/flutter/lib/src/gestures/velocity_tracker.dart
View file @
224e6aa1
...
...
@@ -18,7 +18,7 @@ class Velocity {
/// The [pixelsPerSecond] argument must not be null.
const
Velocity
({
required
this
.
pixelsPerSecond
,
})
:
assert
(
pixelsPerSecond
!=
null
)
;
});
/// A velocity that isn't moving at all.
static
const
Velocity
zero
=
Velocity
(
pixelsPerSecond:
Offset
.
zero
);
...
...
@@ -50,8 +50,8 @@ class Velocity {
/// If the magnitude of this Velocity is within the specified bounds then
/// just return this.
Velocity
clampMagnitude
(
double
minValue
,
double
maxValue
)
{
assert
(
minValue
!=
null
&&
minValue
>=
0.0
);
assert
(
maxValue
!=
null
&&
maxValue
>=
0.0
&&
maxValue
>=
minValue
);
assert
(
minValue
>=
0.0
);
assert
(
maxValue
>=
0.0
&&
maxValue
>=
minValue
);
final
double
valueSquared
=
pixelsPerSecond
.
distanceSquared
;
if
(
valueSquared
>
maxValue
*
maxValue
)
{
return
Velocity
(
pixelsPerSecond:
(
pixelsPerSecond
/
pixelsPerSecond
.
distance
)
*
maxValue
);
...
...
@@ -97,10 +97,7 @@ class VelocityEstimate {
required
this
.
confidence
,
required
this
.
duration
,
required
this
.
offset
,
})
:
assert
(
pixelsPerSecond
!=
null
),
assert
(
confidence
!=
null
),
assert
(
duration
!=
null
),
assert
(
offset
!=
null
);
});
/// The number of pixels per second of velocity in the x and y directions.
final
Offset
pixelsPerSecond
;
...
...
@@ -124,9 +121,7 @@ class VelocityEstimate {
}
class
_PointAtTime
{
const
_PointAtTime
(
this
.
point
,
this
.
time
)
:
assert
(
point
!=
null
),
assert
(
time
!=
null
);
const
_PointAtTime
(
this
.
point
,
this
.
time
);
final
Duration
time
;
final
Offset
point
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment