mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
migrate physics to nullsafety (#61941)
This commit is contained in:
parent
b50b5eadb0
commit
a07219a310
@ -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.
|
||||
///
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user