From a07219a31015cc2feebc9ad02072e3373efd0b1a Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Thu, 23 Jul 2020 17:41:04 +0200 Subject: [PATCH] migrate physics to nullsafety (#61941) --- packages/flutter/lib/physics.dart | 2 -- .../flutter/lib/src/physics/clamped_simulation.dart | 2 -- .../flutter/lib/src/physics/friction_simulation.dart | 2 -- .../flutter/lib/src/physics/gravity_simulation.dart | 2 -- packages/flutter/lib/src/physics/simulation.dart | 2 -- .../flutter/lib/src/physics/spring_simulation.dart | 12 +++++------- packages/flutter/lib/src/physics/tolerance.dart | 2 -- packages/flutter/lib/src/physics/utils.dart | 4 +--- 8 files changed, 6 insertions(+), 22 deletions(-) diff --git a/packages/flutter/lib/physics.dart b/packages/flutter/lib/physics.dart index fd5284ec5a0..24755236995 100644 --- a/packages/flutter/lib/physics.dart +++ b/packages/flutter/lib/physics.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - /// Simple one-dimensional physics simulations, such as springs, friction, and /// gravity, for use in user interface animations. /// diff --git a/packages/flutter/lib/src/physics/clamped_simulation.dart b/packages/flutter/lib/src/physics/clamped_simulation.dart index 0b21c36c603..d5fa6e22d0b 100644 --- a/packages/flutter/lib/src/physics/clamped_simulation.dart +++ b/packages/flutter/lib/src/physics/clamped_simulation.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'simulation.dart'; /// A simulation that applies limits to another simulation. diff --git a/packages/flutter/lib/src/physics/friction_simulation.dart b/packages/flutter/lib/src/physics/friction_simulation.dart index efa89c69a3a..a416c78464f 100644 --- a/packages/flutter/lib/src/physics/friction_simulation.dart +++ b/packages/flutter/lib/src/physics/friction_simulation.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:math' as math; import 'simulation.dart'; diff --git a/packages/flutter/lib/src/physics/gravity_simulation.dart b/packages/flutter/lib/src/physics/gravity_simulation.dart index df76856897f..4f3bdf2f214 100644 --- a/packages/flutter/lib/src/physics/gravity_simulation.dart +++ b/packages/flutter/lib/src/physics/gravity_simulation.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'simulation.dart'; // Examples can assume: diff --git a/packages/flutter/lib/src/physics/simulation.dart b/packages/flutter/lib/src/physics/simulation.dart index 0575e8c4a36..fc6732185ee 100644 --- a/packages/flutter/lib/src/physics/simulation.dart +++ b/packages/flutter/lib/src/physics/simulation.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:flutter/foundation.dart'; import 'tolerance.dart'; diff --git a/packages/flutter/lib/src/physics/spring_simulation.dart b/packages/flutter/lib/src/physics/spring_simulation.dart index 0085c2532bf..ff5b7117e41 100644 --- a/packages/flutter/lib/src/physics/spring_simulation.dart +++ b/packages/flutter/lib/src/physics/spring_simulation.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:math' as math; import 'package:flutter/foundation.dart'; @@ -20,9 +18,9 @@ class SpringDescription { /// /// See [mass], [stiffness], and [damping] for the units of the arguments. const SpringDescription({ - this.mass, - this.stiffness, - this.damping, + required this.mass, + required this.stiffness, + required this.damping, }); /// Creates a spring given the mass (m), stiffness (k), and damping ratio (ΞΆ). @@ -33,8 +31,8 @@ class SpringDescription { /// See [mass] and [stiffness] for the units for those arguments. The damping /// ratio is unitless. SpringDescription.withDampingRatio({ - this.mass, - this.stiffness, + required this.mass, + required this.stiffness, double ratio = 1.0, }) : damping = ratio * 2.0 * math.sqrt(mass * stiffness); diff --git a/packages/flutter/lib/src/physics/tolerance.dart b/packages/flutter/lib/src/physics/tolerance.dart index 58d7235d9b3..6351a2dbbb7 100644 --- a/packages/flutter/lib/src/physics/tolerance.dart +++ b/packages/flutter/lib/src/physics/tolerance.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - /// Structure that specifies maximum allowable magnitudes for distances, /// durations, and velocity differences to be considered equal. class Tolerance { diff --git a/packages/flutter/lib/src/physics/utils.dart b/packages/flutter/lib/src/physics/utils.dart index 9d760a36236..252bd173d5b 100644 --- a/packages/flutter/lib/src/physics/utils.dart +++ b/packages/flutter/lib/src/physics/utils.dart @@ -2,14 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - /// Whether two doubles are within a given distance of each other. /// /// The `epsilon` argument must be positive and not null. /// The `a` and `b` arguments may be null. A null value is only considered /// near-equal to another null value. -bool nearEqual(double a, double b, double epsilon) { +bool nearEqual(double? a, double? b, double epsilon) { assert(epsilon != null); assert(epsilon >= 0.0); if (a == null || b == null)