"Fossies" - the Fresh Open Source Software Archive

Member "flutter-1.22.4/packages/flutter/lib/src/physics/utils.dart" (13 Nov 2020, 805 Bytes) of package /linux/misc/flutter-1.22.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Dart source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Copyright 2014 The Flutter Authors. All rights reserved.
    2 // Use of this source code is governed by a BSD-style license that can be
    3 // found in the LICENSE file.
    4 
    5 /// Whether two doubles are within a given distance of each other.
    6 ///
    7 /// The `epsilon` argument must be positive and not null.
    8 /// The `a` and `b` arguments may be null. A null value is only considered
    9 /// near-equal to another null value.
   10 bool nearEqual(double? a, double? b, double epsilon) {
   11   assert(epsilon != null);
   12   assert(epsilon >= 0.0);
   13   if (a == null || b == null)
   14     return a == b;
   15   return (a > (b - epsilon)) && (a < (b + epsilon)) || a == b;
   16 }
   17 
   18 /// Whether a double is within a given distance of zero.
   19 ///
   20 /// The epsilon argument must be positive.
   21 bool nearZero(double a, double epsilon) => nearEqual(a, 0.0, epsilon);