Merge pull request #1197 from abarth/rm_clamp
Remove clamp() in favour of double.clamp()
This commit is contained in:
commit
193ed22b63
@ -29,11 +29,11 @@ class SectorConstraints extends Constraints {
|
|||||||
final double maxDeltaTheta;
|
final double maxDeltaTheta;
|
||||||
|
|
||||||
double constrainDeltaRadius(double deltaRadius) {
|
double constrainDeltaRadius(double deltaRadius) {
|
||||||
return clamp(min: minDeltaRadius, max: maxDeltaRadius, value: deltaRadius);
|
return deltaRadius.clamp(minDeltaRadius, maxDeltaRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
double constrainDeltaTheta(double deltaTheta) {
|
double constrainDeltaTheta(double deltaTheta) {
|
||||||
return clamp(min: minDeltaTheta, max: maxDeltaTheta, value: deltaTheta);
|
return deltaTheta.clamp(minDeltaTheta, maxDeltaTheta);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get isTight => minDeltaTheta >= maxDeltaTheta && minDeltaTheta >= maxDeltaTheta;
|
bool get isTight => minDeltaTheta >= maxDeltaTheta && minDeltaTheta >= maxDeltaTheta;
|
||||||
|
@ -126,10 +126,10 @@ class BoxConstraints extends Constraints {
|
|||||||
/// as close as possible to the original constraints.
|
/// as close as possible to the original constraints.
|
||||||
BoxConstraints enforce(BoxConstraints constraints) {
|
BoxConstraints enforce(BoxConstraints constraints) {
|
||||||
return new BoxConstraints(
|
return new BoxConstraints(
|
||||||
minWidth: clamp(min: constraints.minWidth, max: constraints.maxWidth, value: minWidth),
|
minWidth: minWidth.clamp(constraints.minWidth, constraints.maxWidth),
|
||||||
maxWidth: clamp(min: constraints.minWidth, max: constraints.maxWidth, value: maxWidth),
|
maxWidth: maxWidth.clamp(constraints.minWidth, constraints.maxWidth),
|
||||||
minHeight: clamp(min: constraints.minHeight, max: constraints.maxHeight, value: minHeight),
|
minHeight: minHeight.clamp(constraints.minHeight, constraints.maxHeight),
|
||||||
maxHeight: clamp(min: constraints.minHeight, max: constraints.maxHeight, value: maxHeight)
|
maxHeight: maxHeight.clamp(constraints.minHeight, constraints.maxHeight)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,10 +137,10 @@ class BoxConstraints extends Constraints {
|
|||||||
/// the given width and height as possible while still respecting the original
|
/// the given width and height as possible while still respecting the original
|
||||||
/// box constraints.
|
/// box constraints.
|
||||||
BoxConstraints tighten({ double width, double height }) {
|
BoxConstraints tighten({ double width, double height }) {
|
||||||
return new BoxConstraints(minWidth: width == null ? minWidth : math.max(math.min(maxWidth, width), minWidth),
|
return new BoxConstraints(minWidth: width == null ? minWidth : width.clamp(minWidth, maxWidth),
|
||||||
maxWidth: width == null ? maxWidth : math.max(math.min(maxWidth, width), minWidth),
|
maxWidth: width == null ? maxWidth : width.clamp(minWidth, maxWidth),
|
||||||
minHeight: height == null ? minHeight : math.max(math.min(maxHeight, height), minHeight),
|
minHeight: height == null ? minHeight : height.clamp(minHeight, maxHeight),
|
||||||
maxHeight: height == null ? maxHeight : math.max(math.min(maxHeight, height), minHeight));
|
maxHeight: height == null ? maxHeight : height.clamp(minHeight, maxHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns box constraints with the same width constraints but with
|
/// Returns box constraints with the same width constraints but with
|
||||||
@ -155,14 +155,14 @@ class BoxConstraints extends Constraints {
|
|||||||
/// possible to the given width.
|
/// possible to the given width.
|
||||||
double constrainWidth([double width = double.INFINITY]) {
|
double constrainWidth([double width = double.INFINITY]) {
|
||||||
assert(isNormalized);
|
assert(isNormalized);
|
||||||
return clamp(min: minWidth, max: maxWidth, value: width);
|
return width.clamp(minWidth, maxWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the height that both satisfies the constraints and is as close as
|
/// Returns the height that both satisfies the constraints and is as close as
|
||||||
/// possible to the given height.
|
/// possible to the given height.
|
||||||
double constrainHeight([double height = double.INFINITY]) {
|
double constrainHeight([double height = double.INFINITY]) {
|
||||||
assert(isNormalized);
|
assert(isNormalized);
|
||||||
return clamp(min: minHeight, max: maxHeight, value: height);
|
return height.clamp(minHeight, maxHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the size that both satisfies the constraints and is as close as
|
/// Returns the size that both satisfies the constraints and is as close as
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
import 'dart:math' as math;
|
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
@ -1162,15 +1161,6 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Obsolete function that will be removed eventually.
|
|
||||||
double clamp({ double min: 0.0, double value: 0.0, double max: double.INFINITY }) {
|
|
||||||
assert(min != null);
|
|
||||||
assert(value != null);
|
|
||||||
assert(max != null);
|
|
||||||
return math.max(min, math.min(max, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Generic mixin for render objects with one child.
|
/// Generic mixin for render objects with one child.
|
||||||
///
|
///
|
||||||
/// Provides a child model for a render object subclass that has a unique child.
|
/// Provides a child model for a render object subclass that has a unique child.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user