Unverified Commit a07219a3 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

migrate physics to nullsafety (#61941)

parent b50b5ead
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
/// Simple one-dimensional physics simulations, such as springs, friction, and /// Simple one-dimensional physics simulations, such as springs, friction, and
/// gravity, for use in user interface animations. /// gravity, for use in user interface animations.
/// ///
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'simulation.dart'; import 'simulation.dart';
/// A simulation that applies limits to another simulation. /// A simulation that applies limits to another simulation.
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:math' as math; import 'dart:math' as math;
import 'simulation.dart'; import 'simulation.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'simulation.dart'; import 'simulation.dart';
// Examples can assume: // Examples can assume:
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'tolerance.dart'; import 'tolerance.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:math' as math; import 'dart:math' as math;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -20,9 +18,9 @@ class SpringDescription { ...@@ -20,9 +18,9 @@ class SpringDescription {
/// ///
/// See [mass], [stiffness], and [damping] for the units of the arguments. /// See [mass], [stiffness], and [damping] for the units of the arguments.
const SpringDescription({ const SpringDescription({
this.mass, required this.mass,
this.stiffness, required this.stiffness,
this.damping, required this.damping,
}); });
/// Creates a spring given the mass (m), stiffness (k), and damping ratio (ζ). /// Creates a spring given the mass (m), stiffness (k), and damping ratio (ζ).
...@@ -33,8 +31,8 @@ class SpringDescription { ...@@ -33,8 +31,8 @@ class SpringDescription {
/// See [mass] and [stiffness] for the units for those arguments. The damping /// See [mass] and [stiffness] for the units for those arguments. The damping
/// ratio is unitless. /// ratio is unitless.
SpringDescription.withDampingRatio({ SpringDescription.withDampingRatio({
this.mass, required this.mass,
this.stiffness, required this.stiffness,
double ratio = 1.0, double ratio = 1.0,
}) : damping = ratio * 2.0 * math.sqrt(mass * stiffness); }) : damping = ratio * 2.0 * math.sqrt(mass * stiffness);
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
/// Structure that specifies maximum allowable magnitudes for distances, /// Structure that specifies maximum allowable magnitudes for distances,
/// durations, and velocity differences to be considered equal. /// durations, and velocity differences to be considered equal.
class Tolerance { class Tolerance {
......
...@@ -2,14 +2,12 @@ ...@@ -2,14 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
/// Whether two doubles are within a given distance of each other. /// Whether two doubles are within a given distance of each other.
/// ///
/// The `epsilon` argument must be positive and not null. /// The `epsilon` argument must be positive and not null.
/// The `a` and `b` arguments may be null. A null value is only considered /// The `a` and `b` arguments may be null. A null value is only considered
/// near-equal to another null value. /// 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 != null);
assert(epsilon >= 0.0); assert(epsilon >= 0.0);
if (a == null || b == null) if (a == null || b == null)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment