From a6c4927b27933fafc7a53ab00ef290173244cedb Mon Sep 17 00:00:00 2001 From: "P.Y. Laligand" Date: Wed, 17 Feb 2016 15:58:19 -0800 Subject: [PATCH] Added a few operators to the Velocity class. #1968 --- .../flutter/lib/src/gestures/velocity_tracker.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/flutter/lib/src/gestures/velocity_tracker.dart b/packages/flutter/lib/src/gestures/velocity_tracker.dart index 27fe9b4b32f..fe2ca138889 100644 --- a/packages/flutter/lib/src/gestures/velocity_tracker.dart +++ b/packages/flutter/lib/src/gestures/velocity_tracker.dart @@ -218,6 +218,16 @@ class Velocity { /// The number of pixels per second of velocity in the x and y directions. final Offset pixelsPerSecond; + Velocity operator -() => new Velocity(pixelsPerSecond: -pixelsPerSecond); + Velocity operator -(Velocity other) { + return new Velocity( + pixelsPerSecond: pixelsPerSecond - other.pixelsPerSecond); + } + Velocity operator +(Velocity other) { + return new Velocity( + pixelsPerSecond: pixelsPerSecond + other.pixelsPerSecond); + } + bool operator ==(dynamic other) { if (other is! Velocity) return false;