Unverified Commit 7272c809 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Remove unnecessary null checks in `flutter/{animation,semantics,scheduler}` (#118922)

* Remove unnecessary null checks in flutter/animation

* Remove unnecessary null checks in flutter/semantics

* Remove unnecessary null checks in flutter/scheduler
parent 5d74b5cb
...@@ -269,7 +269,6 @@ abstract class Animation<T> extends Listenable implements ValueListenable<T> { ...@@ -269,7 +269,6 @@ abstract class Animation<T> extends Listenable implements ValueListenable<T> {
/// * "&#x23ED;": [AnimationStatus.completed] ([value] == 1.0) /// * "&#x23ED;": [AnimationStatus.completed] ([value] == 1.0)
/// * "&#x23EE;": [AnimationStatus.dismissed] ([value] == 0.0) /// * "&#x23EE;": [AnimationStatus.dismissed] ([value] == 0.0)
String toStringDetails() { String toStringDetails() {
assert(status != null);
switch (status) { switch (status) {
case AnimationStatus.forward: case AnimationStatus.forward:
return '\u25B6'; // > return '\u25B6'; // >
......
...@@ -242,10 +242,7 @@ class AnimationController extends Animation<double> ...@@ -242,10 +242,7 @@ class AnimationController extends Animation<double>
this.upperBound = 1.0, this.upperBound = 1.0,
this.animationBehavior = AnimationBehavior.normal, this.animationBehavior = AnimationBehavior.normal,
required TickerProvider vsync, required TickerProvider vsync,
}) : assert(lowerBound != null), }) : assert(upperBound >= lowerBound),
assert(upperBound != null),
assert(upperBound >= lowerBound),
assert(vsync != null),
_direction = _AnimationDirection.forward { _direction = _AnimationDirection.forward {
_ticker = vsync.createTicker(_tick); _ticker = vsync.createTicker(_tick);
_internalSetValue(value ?? lowerBound); _internalSetValue(value ?? lowerBound);
...@@ -275,9 +272,7 @@ class AnimationController extends Animation<double> ...@@ -275,9 +272,7 @@ class AnimationController extends Animation<double>
this.debugLabel, this.debugLabel,
required TickerProvider vsync, required TickerProvider vsync,
this.animationBehavior = AnimationBehavior.preserve, this.animationBehavior = AnimationBehavior.preserve,
}) : assert(value != null), }) : lowerBound = double.negativeInfinity,
assert(vsync != null),
lowerBound = double.negativeInfinity,
upperBound = double.infinity, upperBound = double.infinity,
_direction = _AnimationDirection.forward { _direction = _AnimationDirection.forward {
_ticker = vsync.createTicker(_tick); _ticker = vsync.createTicker(_tick);
...@@ -363,7 +358,6 @@ class AnimationController extends Animation<double> ...@@ -363,7 +358,6 @@ class AnimationController extends Animation<double>
/// * [forward], [reverse], [animateTo], [animateWith], [fling], and [repeat], /// * [forward], [reverse], [animateTo], [animateWith], [fling], and [repeat],
/// which start the animation controller. /// which start the animation controller.
set value(double newValue) { set value(double newValue) {
assert(newValue != null);
stop(); stop();
_internalSetValue(newValue); _internalSetValue(newValue);
notifyListeners(); notifyListeners();
...@@ -657,7 +651,6 @@ class AnimationController extends Animation<double> ...@@ -657,7 +651,6 @@ class AnimationController extends Animation<double>
}()); }());
assert(max >= min); assert(max >= min);
assert(max <= upperBound && min >= lowerBound); assert(max <= upperBound && min >= lowerBound);
assert(reverse != null);
stop(); stop();
return _startSimulation(_RepeatingSimulation(_value, min, max, reverse, period!, _directionSetter)); return _startSimulation(_RepeatingSimulation(_value, min, max, reverse, period!, _directionSetter));
} }
...@@ -744,7 +737,6 @@ class AnimationController extends Animation<double> ...@@ -744,7 +737,6 @@ class AnimationController extends Animation<double>
} }
TickerFuture _startSimulation(Simulation simulation) { TickerFuture _startSimulation(Simulation simulation) {
assert(simulation != null);
assert(!isAnimating); assert(!isAnimating);
_simulation = simulation; _simulation = simulation;
_lastElapsedDuration = Duration.zero; _lastElapsedDuration = Duration.zero;
...@@ -856,9 +848,7 @@ class AnimationController extends Animation<double> ...@@ -856,9 +848,7 @@ class AnimationController extends Animation<double>
class _InterpolationSimulation extends Simulation { class _InterpolationSimulation extends Simulation {
_InterpolationSimulation(this._begin, this._end, Duration duration, this._curve, double scale) _InterpolationSimulation(this._begin, this._end, Duration duration, this._curve, double scale)
: assert(_begin != null), : assert(duration.inMicroseconds > 0),
assert(_end != null),
assert(duration != null && duration.inMicroseconds > 0),
_durationInSeconds = (duration.inMicroseconds * scale) / Duration.microsecondsPerSecond; _durationInSeconds = (duration.inMicroseconds * scale) / Duration.microsecondsPerSecond;
final double _durationInSeconds; final double _durationInSeconds;
......
...@@ -271,8 +271,7 @@ class ReverseAnimation extends Animation<double> ...@@ -271,8 +271,7 @@ class ReverseAnimation extends Animation<double>
/// Creates a reverse animation. /// Creates a reverse animation.
/// ///
/// The parent argument must not be null. /// The parent argument must not be null.
ReverseAnimation(this.parent) ReverseAnimation(this.parent);
: assert(parent != null);
/// The animation whose value and direction this animation is reversing. /// The animation whose value and direction this animation is reversing.
final Animation<double> parent; final Animation<double> parent;
...@@ -310,7 +309,6 @@ class ReverseAnimation extends Animation<double> ...@@ -310,7 +309,6 @@ class ReverseAnimation extends Animation<double>
double get value => 1.0 - parent.value; double get value => 1.0 - parent.value;
AnimationStatus _reverseStatus(AnimationStatus status) { AnimationStatus _reverseStatus(AnimationStatus status) {
assert(status != null);
switch (status) { switch (status) {
case AnimationStatus.forward: return AnimationStatus.reverse; case AnimationStatus.forward: return AnimationStatus.reverse;
case AnimationStatus.reverse: return AnimationStatus.forward; case AnimationStatus.reverse: return AnimationStatus.forward;
...@@ -384,8 +382,7 @@ class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<do ...@@ -384,8 +382,7 @@ class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<do
required this.parent, required this.parent,
required this.curve, required this.curve,
this.reverseCurve, this.reverseCurve,
}) : assert(parent != null), }) {
assert(curve != null) {
_updateCurveDirection(parent.status); _updateCurveDirection(parent.status);
parent.addStatusListener(_updateCurveDirection); parent.addStatusListener(_updateCurveDirection);
} }
...@@ -518,7 +515,7 @@ class TrainHoppingAnimation extends Animation<double> ...@@ -518,7 +515,7 @@ class TrainHoppingAnimation extends Animation<double>
Animation<double> this._currentTrain, Animation<double> this._currentTrain,
this._nextTrain, { this._nextTrain, {
this.onSwitchedTrain, this.onSwitchedTrain,
}) : assert(_currentTrain != null) { }) {
if (_nextTrain != null) { if (_nextTrain != null) {
if (_currentTrain!.value == _nextTrain!.value) { if (_currentTrain!.value == _nextTrain!.value) {
_currentTrain = _nextTrain; _currentTrain = _nextTrain;
...@@ -644,8 +641,7 @@ abstract class CompoundAnimation<T> extends Animation<T> ...@@ -644,8 +641,7 @@ abstract class CompoundAnimation<T> extends Animation<T>
CompoundAnimation({ CompoundAnimation({
required this.first, required this.first,
required this.next, required this.next,
}) : assert(first != null), });
assert(next != null);
/// The first sub-animation. Its status takes precedence if neither are /// The first sub-animation. Its status takes precedence if neither are
/// animating. /// animating.
......
...@@ -35,7 +35,6 @@ abstract class ParametricCurve<T> { ...@@ -35,7 +35,6 @@ abstract class ParametricCurve<T> {
/// implementation of [transform], which delegates the remaining logic to /// implementation of [transform], which delegates the remaining logic to
/// [transformInternal]. /// [transformInternal].
T transform(double t) { T transform(double t) {
assert(t != null);
assert(t >= 0.0 && t <= 1.0, 'parametric value $t is outside of [0, 1] range.'); assert(t >= 0.0 && t <= 1.0, 'parametric value $t is outside of [0, 1] range.');
return transformInternal(t); return transformInternal(t);
} }
...@@ -129,7 +128,7 @@ class SawTooth extends Curve { ...@@ -129,7 +128,7 @@ class SawTooth extends Curve {
/// Creates a sawtooth curve. /// Creates a sawtooth curve.
/// ///
/// The [count] argument must not be null. /// The [count] argument must not be null.
const SawTooth(this.count) : assert(count != null); const SawTooth(this.count);
/// The number of repetitions of the sawtooth pattern in the unit interval. /// The number of repetitions of the sawtooth pattern in the unit interval.
final int count; final int count;
...@@ -159,10 +158,7 @@ class Interval extends Curve { ...@@ -159,10 +158,7 @@ class Interval extends Curve {
/// Creates an interval curve. /// Creates an interval curve.
/// ///
/// The arguments must not be null. /// The arguments must not be null.
const Interval(this.begin, this.end, { this.curve = Curves.linear }) const Interval(this.begin, this.end, { this.curve = Curves.linear });
: assert(begin != null),
assert(end != null),
assert(curve != null);
/// The largest value for which this interval is 0.0. /// The largest value for which this interval is 0.0.
/// ///
...@@ -207,7 +203,7 @@ class Threshold extends Curve { ...@@ -207,7 +203,7 @@ class Threshold extends Curve {
/// Creates a threshold curve. /// Creates a threshold curve.
/// ///
/// The [threshold] argument must not be null. /// The [threshold] argument must not be null.
const Threshold(this.threshold) : assert(threshold != null); const Threshold(this.threshold);
/// The value before which the curve is 0.0 and after which the curve is 1.0. /// The value before which the curve is 0.0 and after which the curve is 1.0.
/// ///
...@@ -307,11 +303,7 @@ class Cubic extends Curve { ...@@ -307,11 +303,7 @@ class Cubic extends Curve {
/// cubic curves in [Curves]. /// cubic curves in [Curves].
/// ///
/// The [a] (x1), [b] (y1), [c] (x2) and [d] (y2) arguments must not be null. /// The [a] (x1), [b] (y1), [c] (x2) and [d] (y2) arguments must not be null.
const Cubic(this.a, this.b, this.c, this.d) const Cubic(this.a, this.b, this.c, this.d);
: assert(a != null),
assert(b != null),
assert(c != null),
assert(d != null);
/// The x coordinate of the first control point. /// The x coordinate of the first control point.
/// ///
...@@ -518,9 +510,6 @@ abstract class Curve2D extends ParametricCurve<Offset> { ...@@ -518,9 +510,6 @@ abstract class Curve2D extends ParametricCurve<Offset> {
// 4. Recursively sample the two parts. // 4. Recursively sample the two parts.
// //
// This algorithm concentrates samples in areas of high curvature. // This algorithm concentrates samples in areas of high curvature.
assert(tolerance != null);
assert(start != null);
assert(end != null);
assert(end > start); assert(end > start);
// We want to pick a random seed that will keep the result stable if // We want to pick a random seed that will keep the result stable if
// evaluated again, so we use the first non-generated control point. // evaluated again, so we use the first non-generated control point.
...@@ -577,7 +566,6 @@ abstract class Curve2D extends ParametricCurve<Offset> { ...@@ -577,7 +566,6 @@ abstract class Curve2D extends ParametricCurve<Offset> {
/// single-valued, it will return the parameter for only one of the values at /// single-valued, it will return the parameter for only one of the values at
/// the given `x` location. /// the given `x` location.
double findInverse(double x) { double findInverse(double x) {
assert(x != null);
double start = 0.0; double start = 0.0;
double end = 1.0; double end = 1.0;
late double mid; late double mid;
...@@ -612,7 +600,7 @@ class Curve2DSample { ...@@ -612,7 +600,7 @@ class Curve2DSample {
/// Creates an object that holds a sample; used with [Curve2D] subclasses. /// Creates an object that holds a sample; used with [Curve2D] subclasses.
/// ///
/// All arguments must not be null. /// All arguments must not be null.
const Curve2DSample(this.t, this.value) : assert(t != null), assert(value != null); const Curve2DSample(this.t, this.value);
/// The parametric location of this sample point along the curve. /// The parametric location of this sample point along the curve.
final double t; final double t;
...@@ -682,9 +670,7 @@ class CatmullRomSpline extends Curve2D { ...@@ -682,9 +670,7 @@ class CatmullRomSpline extends Curve2D {
double tension = 0.0, double tension = 0.0,
Offset? startHandle, Offset? startHandle,
Offset? endHandle, Offset? endHandle,
}) : assert(controlPoints != null), }) : assert(tension <= 1.0, 'tension $tension must not be greater than 1.0.'),
assert(tension != null),
assert(tension <= 1.0, 'tension $tension must not be greater than 1.0.'),
assert(tension >= 0.0, 'tension $tension must not be negative.'), assert(tension >= 0.0, 'tension $tension must not be negative.'),
assert(controlPoints.length > 3, 'There must be at least four control points to create a CatmullRomSpline.'), assert(controlPoints.length > 3, 'There must be at least four control points to create a CatmullRomSpline.'),
_controlPoints = controlPoints, _controlPoints = controlPoints,
...@@ -702,9 +688,7 @@ class CatmullRomSpline extends Curve2D { ...@@ -702,9 +688,7 @@ class CatmullRomSpline extends Curve2D {
double tension = 0.0, double tension = 0.0,
Offset? startHandle, Offset? startHandle,
Offset? endHandle, Offset? endHandle,
}) : assert(controlPoints != null), }) : assert(tension <= 1.0, 'tension $tension must not be greater than 1.0.'),
assert(tension != null),
assert(tension <= 1.0, 'tension $tension must not be greater than 1.0.'),
assert(tension >= 0.0, 'tension $tension must not be negative.'), assert(tension >= 0.0, 'tension $tension must not be negative.'),
assert(controlPoints.length > 3, 'There must be at least four control points to create a CatmullRomSpline.'), assert(controlPoints.length > 3, 'There must be at least four control points to create a CatmullRomSpline.'),
_controlPoints = null, _controlPoints = null,
...@@ -860,8 +844,7 @@ class CatmullRomCurve extends Curve { ...@@ -860,8 +844,7 @@ class CatmullRomCurve extends Curve {
/// ///
/// * This [paper on using Catmull-Rom splines](http://faculty.cs.tamu.edu/schaefer/research/cr_cad.pdf). /// * This [paper on using Catmull-Rom splines](http://faculty.cs.tamu.edu/schaefer/research/cr_cad.pdf).
CatmullRomCurve(this.controlPoints, {this.tension = 0.0}) CatmullRomCurve(this.controlPoints, {this.tension = 0.0})
: assert(tension != null), : assert(() {
assert(() {
return validateControlPoints( return validateControlPoints(
controlPoints, controlPoints,
tension: tension, tension: tension,
...@@ -877,8 +860,7 @@ class CatmullRomCurve extends Curve { ...@@ -877,8 +860,7 @@ class CatmullRomCurve extends Curve {
/// Same as [CatmullRomCurve.new], but it precomputes the internal curve data /// Same as [CatmullRomCurve.new], but it precomputes the internal curve data
/// structures for a more predictable computation load. /// structures for a more predictable computation load.
CatmullRomCurve.precompute(this.controlPoints, {this.tension = 0.0}) CatmullRomCurve.precompute(this.controlPoints, {this.tension = 0.0})
: assert(tension != null), : assert(() {
assert(() {
return validateControlPoints( return validateControlPoints(
controlPoints, controlPoints,
tension: tension, tension: tension,
...@@ -963,7 +945,6 @@ class CatmullRomCurve extends Curve { ...@@ -963,7 +945,6 @@ class CatmullRomCurve extends Curve {
double tension = 0.0, double tension = 0.0,
List<String>? reasons, List<String>? reasons,
}) { }) {
assert(tension != null);
if (controlPoints == null) { if (controlPoints == null) {
assert(() { assert(() {
reasons?.add('Supplied control points cannot be null'); reasons?.add('Supplied control points cannot be null');
...@@ -1143,7 +1124,7 @@ class FlippedCurve extends Curve { ...@@ -1143,7 +1124,7 @@ class FlippedCurve extends Curve {
/// Creates a flipped curve. /// Creates a flipped curve.
/// ///
/// The [curve] argument must not be null. /// The [curve] argument must not be null.
const FlippedCurve(this.curve) : assert(curve != null); const FlippedCurve(this.curve);
/// The curve that is being flipped. /// The curve that is being flipped.
final Curve curve; final Curve curve;
......
...@@ -364,8 +364,7 @@ class Tween<T extends Object?> extends Animatable<T> { ...@@ -364,8 +364,7 @@ class Tween<T extends Object?> extends Animatable<T> {
class ReverseTween<T extends Object?> extends Tween<T> { class ReverseTween<T extends Object?> extends Tween<T> {
/// Construct a [Tween] that evaluates its [parent] in reverse. /// Construct a [Tween] that evaluates its [parent] in reverse.
ReverseTween(this.parent) ReverseTween(this.parent)
: assert(parent != null), : super(begin: parent.end, end: parent.begin);
super(begin: parent.end, end: parent.begin);
/// This tween's value is the same as the parent's value evaluated in reverse. /// This tween's value is the same as the parent's value evaluated in reverse.
/// ///
...@@ -544,8 +543,7 @@ class CurveTween extends Animatable<double> { ...@@ -544,8 +543,7 @@ class CurveTween extends Animatable<double> {
/// Creates a curve tween. /// Creates a curve tween.
/// ///
/// The [curve] argument must not be null. /// The [curve] argument must not be null.
CurveTween({ required this.curve }) CurveTween({ required this.curve });
: assert(curve != null);
/// The curve to use when transforming the value of the animation. /// The curve to use when transforming the value of the animation.
Curve curve; Curve curve;
......
...@@ -51,8 +51,7 @@ class TweenSequence<T> extends Animatable<T> { ...@@ -51,8 +51,7 @@ class TweenSequence<T> extends Animatable<T> {
/// best to reuse one, rather than rebuilding it on every frame, when that's /// best to reuse one, rather than rebuilding it on every frame, when that's
/// possible. /// possible.
TweenSequence(List<TweenSequenceItem<T>> items) TweenSequence(List<TweenSequenceItem<T>> items)
: assert(items != null), : assert(items.isNotEmpty) {
assert(items.isNotEmpty) {
_items.addAll(items); _items.addAll(items);
double totalWeight = 0.0; double totalWeight = 0.0;
...@@ -113,8 +112,7 @@ class FlippedTweenSequence extends TweenSequence<double> { ...@@ -113,8 +112,7 @@ class FlippedTweenSequence extends TweenSequence<double> {
/// There's a small cost associated with building a `TweenSequence` so it's /// There's a small cost associated with building a `TweenSequence` so it's
/// best to reuse one, rather than rebuilding it on every frame, when that's /// best to reuse one, rather than rebuilding it on every frame, when that's
/// possible. /// possible.
FlippedTweenSequence(super.items) FlippedTweenSequence(super.items);
: assert(items != null);
@override @override
double transform(double t) => 1 - super.transform(1 - t); double transform(double t) => 1 - super.transform(1 - t);
...@@ -128,9 +126,7 @@ class TweenSequenceItem<T> { ...@@ -128,9 +126,7 @@ class TweenSequenceItem<T> {
const TweenSequenceItem({ const TweenSequenceItem({
required this.tween, required this.tween,
required this.weight, required this.weight,
}) : assert(tween != null), }) : assert(weight > 0.0);
assert(weight != null),
assert(weight > 0.0);
/// Defines the value of the [TweenSequence] for the interval within the /// Defines the value of the [TweenSequence] for the interval within the
/// animation's duration indicated by [weight] and this item's position /// animation's duration indicated by [weight] and this item's position
......
...@@ -385,7 +385,6 @@ mixin SchedulerBinding on BindingBase { ...@@ -385,7 +385,6 @@ mixin SchedulerBinding on BindingBase {
@protected @protected
@mustCallSuper @mustCallSuper
void handleAppLifecycleStateChanged(AppLifecycleState state) { void handleAppLifecycleStateChanged(AppLifecycleState state) {
assert(state != null);
_lifecycleState = state; _lifecycleState = state;
switch (state) { switch (state) {
case AppLifecycleState.resumed: case AppLifecycleState.resumed:
...@@ -1026,7 +1025,6 @@ mixin SchedulerBinding on BindingBase { ...@@ -1026,7 +1025,6 @@ mixin SchedulerBinding on BindingBase {
/// presentation time, and can be used to ensure that animations running in /// presentation time, and can be used to ensure that animations running in
/// different processes are synchronized. /// different processes are synchronized.
Duration get currentSystemFrameTimeStamp { Duration get currentSystemFrameTimeStamp {
assert(_lastRawTimeStamp != null);
return _lastRawTimeStamp; return _lastRawTimeStamp;
} }
...@@ -1279,7 +1277,6 @@ mixin SchedulerBinding on BindingBase { ...@@ -1279,7 +1277,6 @@ mixin SchedulerBinding on BindingBase {
// the error. // the error.
@pragma('vm:notify-debugger-on-exception') @pragma('vm:notify-debugger-on-exception')
void _invokeFrameCallback(FrameCallback callback, Duration timeStamp, [ StackTrace? callbackStack ]) { void _invokeFrameCallback(FrameCallback callback, Duration timeStamp, [ StackTrace? callbackStack ]) {
assert(callback != null);
assert(_FrameCallbackEntry.debugCurrentCallbackStack == null); assert(_FrameCallbackEntry.debugCurrentCallbackStack == null);
assert(() { assert(() {
_FrameCallbackEntry.debugCurrentCallbackStack = callbackStack; _FrameCallbackEntry.debugCurrentCallbackStack = callbackStack;
......
...@@ -211,8 +211,7 @@ class CustomSemanticsAction { ...@@ -211,8 +211,7 @@ class CustomSemanticsAction {
/// ///
/// The [label] must not be null or the empty string. /// The [label] must not be null or the empty string.
const CustomSemanticsAction({required String this.label}) const CustomSemanticsAction({required String this.label})
: assert(label != null), : assert(label != ''),
assert(label != ''),
hint = null, hint = null,
action = null; action = null;
...@@ -221,9 +220,7 @@ class CustomSemanticsAction { ...@@ -221,9 +220,7 @@ class CustomSemanticsAction {
/// ///
/// The [hint] must not be null or the empty string. /// The [hint] must not be null or the empty string.
const CustomSemanticsAction.overridingAction({required String this.hint, required SemanticsAction this.action}) const CustomSemanticsAction.overridingAction({required String this.hint, required SemanticsAction this.action})
: assert(hint != null), : assert(hint != ''),
assert(hint != ''),
assert(action != null),
label = null; label = null;
/// The user readable name of this custom semantics action. /// The user readable name of this custom semantics action.
...@@ -371,8 +368,7 @@ class AttributedStringProperty extends DiagnosticsProperty<AttributedString> { ...@@ -371,8 +368,7 @@ class AttributedStringProperty extends DiagnosticsProperty<AttributedString> {
super.defaultValue, super.defaultValue,
super.level, super.level,
super.description, super.description,
}) : assert(showName != null), });
assert(level != null);
/// Whether to show the property when the [value] is an [AttributedString] /// Whether to show the property when the [value] is an [AttributedString]
/// whose [AttributedString.string] is the empty string. /// whose [AttributedString.string] is the empty string.
...@@ -441,20 +437,12 @@ class SemanticsData with Diagnosticable { ...@@ -441,20 +437,12 @@ class SemanticsData with Diagnosticable {
this.tags, this.tags,
this.transform, this.transform,
this.customSemanticsActionIds, this.customSemanticsActionIds,
}) : assert(flags != null), }) : assert(tooltip == '' || textDirection != null, 'A SemanticsData object with tooltip "$tooltip" had a null textDirection.'),
assert(actions != null),
assert(attributedLabel != null),
assert(attributedValue != null),
assert(attributedDecreasedValue != null),
assert(attributedIncreasedValue != null),
assert(attributedHint != null),
assert(tooltip == '' || textDirection != null, 'A SemanticsData object with tooltip "$tooltip" had a null textDirection.'),
assert(attributedLabel.string == '' || textDirection != null, 'A SemanticsData object with label "${attributedLabel.string}" had a null textDirection.'), assert(attributedLabel.string == '' || textDirection != null, 'A SemanticsData object with label "${attributedLabel.string}" had a null textDirection.'),
assert(attributedValue.string == '' || textDirection != null, 'A SemanticsData object with value "${attributedValue.string}" had a null textDirection.'), assert(attributedValue.string == '' || textDirection != null, 'A SemanticsData object with value "${attributedValue.string}" had a null textDirection.'),
assert(attributedDecreasedValue.string == '' || textDirection != null, 'A SemanticsData object with decreasedValue "${attributedDecreasedValue.string}" had a null textDirection.'), assert(attributedDecreasedValue.string == '' || textDirection != null, 'A SemanticsData object with decreasedValue "${attributedDecreasedValue.string}" had a null textDirection.'),
assert(attributedIncreasedValue.string == '' || textDirection != null, 'A SemanticsData object with increasedValue "${attributedIncreasedValue.string}" had a null textDirection.'), assert(attributedIncreasedValue.string == '' || textDirection != null, 'A SemanticsData object with increasedValue "${attributedIncreasedValue.string}" had a null textDirection.'),
assert(attributedHint.string == '' || textDirection != null, 'A SemanticsData object with hint "${attributedHint.string}" had a null textDirection.'), assert(attributedHint.string == '' || textDirection != null, 'A SemanticsData object with hint "${attributedHint.string}" had a null textDirection.');
assert(rect != null);
/// A bit field of [SemanticsFlag]s that apply to this node. /// A bit field of [SemanticsFlag]s that apply to this node.
final int flags; final int flags;
...@@ -1721,7 +1709,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { ...@@ -1721,7 +1709,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
Rect get rect => _rect; Rect get rect => _rect;
Rect _rect = Rect.zero; Rect _rect = Rect.zero;
set rect(Rect value) { set rect(Rect value) {
assert(value != null);
assert(value.isFinite, '$this (with $owner) tried to set a non-finite rect.'); assert(value.isFinite, '$this (with $owner) tried to set a non-finite rect.');
if (_rect != value) { if (_rect != value) {
_rect = value; _rect = value;
...@@ -1806,7 +1793,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { ...@@ -1806,7 +1793,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
bool get isMergedIntoParent => _isMergedIntoParent; bool get isMergedIntoParent => _isMergedIntoParent;
bool _isMergedIntoParent = false; bool _isMergedIntoParent = false;
set isMergedIntoParent(bool value) { set isMergedIntoParent(bool value) {
assert(value != null);
if (_isMergedIntoParent == value) { if (_isMergedIntoParent == value) {
return; return;
} }
...@@ -1929,7 +1915,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { ...@@ -1929,7 +1915,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
} }
} }
if (!sawChange && _children != null) { if (!sawChange && _children != null) {
assert(newChildren != null);
assert(newChildren.length == _children!.length); assert(newChildren.length == _children!.length);
// Did the order change? // Did the order change?
for (int i = 0; i < _children!.length; i++) { for (int i = 0; i < _children!.length; i++) {
...@@ -2504,13 +2489,13 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { ...@@ -2504,13 +2489,13 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
platformViewId ??= node._platformViewId; platformViewId ??= node._platformViewId;
maxValueLength ??= node._maxValueLength; maxValueLength ??= node._maxValueLength;
currentValueLength ??= node._currentValueLength; currentValueLength ??= node._currentValueLength;
if (attributedValue == null || attributedValue.string == '') { if (attributedValue.string == '') {
attributedValue = node._attributedValue; attributedValue = node._attributedValue;
} }
if (attributedIncreasedValue == null || attributedIncreasedValue.string == '') { if (attributedIncreasedValue.string == '') {
attributedIncreasedValue = node._attributedIncreasedValue; attributedIncreasedValue = node._attributedIncreasedValue;
} }
if (attributedDecreasedValue == null || attributedDecreasedValue.string == '') { if (attributedDecreasedValue.string == '') {
attributedDecreasedValue = node._attributedDecreasedValue; attributedDecreasedValue = node._attributedDecreasedValue;
} }
if (tooltip == '') { if (tooltip == '') {
...@@ -2808,7 +2793,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { ...@@ -2808,7 +2793,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
DiagnosticLevel minLevel = DiagnosticLevel.debug, DiagnosticLevel minLevel = DiagnosticLevel.debug,
DebugSemanticsDumpOrder childOrder = DebugSemanticsDumpOrder.traversalOrder, DebugSemanticsDumpOrder childOrder = DebugSemanticsDumpOrder.traversalOrder,
}) { }) {
assert(childOrder != null);
return toDiagnosticsNode(childOrder: childOrder).toStringDeep(prefixLineOne: prefixLineOne, prefixOtherLines: prefixOtherLines, minLevel: minLevel); return toDiagnosticsNode(childOrder: childOrder).toStringDeep(prefixLineOne: prefixLineOne, prefixOtherLines: prefixOtherLines, minLevel: minLevel);
} }
...@@ -2835,7 +2819,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { ...@@ -2835,7 +2819,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
/// Returns the list of direct children of this node in the specified order. /// Returns the list of direct children of this node in the specified order.
List<SemanticsNode> debugListChildrenInOrder(DebugSemanticsDumpOrder childOrder) { List<SemanticsNode> debugListChildrenInOrder(DebugSemanticsDumpOrder childOrder) {
assert(childOrder != null);
if (_children == null) { if (_children == null) {
return const <SemanticsNode>[]; return const <SemanticsNode>[];
} }
...@@ -2862,10 +2845,7 @@ class _BoxEdge implements Comparable<_BoxEdge> { ...@@ -2862,10 +2845,7 @@ class _BoxEdge implements Comparable<_BoxEdge> {
required this.isLeadingEdge, required this.isLeadingEdge,
required this.offset, required this.offset,
required this.node, required this.node,
}) : assert(isLeadingEdge != null), }) : assert(offset.isFinite);
assert(offset != null),
assert(offset.isFinite),
assert(node != null);
/// True if the edge comes before the seconds edge along the traversal /// True if the edge comes before the seconds edge along the traversal
/// direction, and false otherwise. /// direction, and false otherwise.
...@@ -2899,7 +2879,7 @@ class _SemanticsSortGroup extends Comparable<_SemanticsSortGroup> { ...@@ -2899,7 +2879,7 @@ class _SemanticsSortGroup extends Comparable<_SemanticsSortGroup> {
_SemanticsSortGroup({ _SemanticsSortGroup({
required this.startOffset, required this.startOffset,
required this.textDirection, required this.textDirection,
}) : assert(startOffset != null); });
/// The offset from the start edge of the parent [SemanticsNode] in the /// The offset from the start edge of the parent [SemanticsNode] in the
/// direction of the traversal. /// direction of the traversal.
...@@ -3122,9 +3102,7 @@ class _TraversalSortNode implements Comparable<_TraversalSortNode> { ...@@ -3122,9 +3102,7 @@ class _TraversalSortNode implements Comparable<_TraversalSortNode> {
required this.node, required this.node,
this.sortKey, this.sortKey,
required this.position, required this.position,
}) });
: assert(node != null),
assert(position != null);
/// The node whose position this sort node determines. /// The node whose position this sort node determines.
final SemanticsNode node; final SemanticsNode node;
...@@ -3263,7 +3241,6 @@ class SemanticsOwner extends ChangeNotifier { ...@@ -3263,7 +3241,6 @@ class SemanticsOwner extends ChangeNotifier {
/// If the given `action` requires arguments they need to be passed in via /// If the given `action` requires arguments they need to be passed in via
/// the `args` parameter. /// the `args` parameter.
void performAction(int id, SemanticsAction action, [ Object? args ]) { void performAction(int id, SemanticsAction action, [ Object? args ]) {
assert(action != null);
final SemanticsActionHandler? handler = _getSemanticsActionHandlerForId(id, action); final SemanticsActionHandler? handler = _getSemanticsActionHandlerForId(id, action);
if (handler != null) { if (handler != null) {
handler(args); handler(args);
...@@ -3317,7 +3294,6 @@ class SemanticsOwner extends ChangeNotifier { ...@@ -3317,7 +3294,6 @@ class SemanticsOwner extends ChangeNotifier {
/// If the given `action` requires arguments they need to be passed in via /// If the given `action` requires arguments they need to be passed in via
/// the `args` parameter. /// the `args` parameter.
void performActionAt(Offset position, SemanticsAction action, [ Object? args ]) { void performActionAt(Offset position, SemanticsAction action, [ Object? args ]) {
assert(action != null);
final SemanticsNode? node = rootSemanticsNode; final SemanticsNode? node = rootSemanticsNode;
if (node == null) { if (node == null) {
return; return;
...@@ -3419,7 +3395,6 @@ class SemanticsConfiguration { ...@@ -3419,7 +3395,6 @@ class SemanticsConfiguration {
/// The provided `handler` is called to respond to the user triggered /// The provided `handler` is called to respond to the user triggered
/// `action`. /// `action`.
void _addAction(SemanticsAction action, SemanticsActionHandler handler) { void _addAction(SemanticsAction action, SemanticsActionHandler handler) {
assert(handler != null);
_actions[action] = handler; _actions[action] = handler;
_actionsAsBits |= action.index; _actionsAsBits |= action.index;
_hasBeenAnnotated = true; _hasBeenAnnotated = true;
...@@ -3431,7 +3406,6 @@ class SemanticsConfiguration { ...@@ -3431,7 +3406,6 @@ class SemanticsConfiguration {
/// The provided `handler` is called to respond to the user triggered /// The provided `handler` is called to respond to the user triggered
/// `action`. /// `action`.
void _addArgumentlessAction(SemanticsAction action, VoidCallback handler) { void _addArgumentlessAction(SemanticsAction action, VoidCallback handler) {
assert(handler != null);
_addAction(action, (Object? args) { _addAction(action, (Object? args) {
assert(args == null); assert(args == null);
handler(); handler();
...@@ -3746,7 +3720,7 @@ class SemanticsConfiguration { ...@@ -3746,7 +3720,7 @@ class SemanticsConfiguration {
_addAction(SemanticsAction.setSelection, (Object? args) { _addAction(SemanticsAction.setSelection, (Object? args) {
assert(args != null && args is Map); assert(args != null && args is Map);
final Map<String, int> selection = (args! as Map<dynamic, dynamic>).cast<String, int>(); final Map<String, int> selection = (args! as Map<dynamic, dynamic>).cast<String, int>();
assert(selection != null && selection['base'] != null && selection['extent'] != null); assert(selection['base'] != null && selection['extent'] != null);
value!(TextSelection( value!(TextSelection(
baseOffset: selection['base']!, baseOffset: selection['base']!,
extentOffset: selection['extent']!, extentOffset: selection['extent']!,
...@@ -4004,7 +3978,6 @@ class SemanticsConfiguration { ...@@ -4004,7 +3978,6 @@ class SemanticsConfiguration {
/// * [attributedLabel], which is the [AttributedString] of this property. /// * [attributedLabel], which is the [AttributedString] of this property.
String get label => _attributedLabel.string; String get label => _attributedLabel.string;
set label(String label) { set label(String label) {
assert(label != null);
_attributedLabel = AttributedString(label); _attributedLabel = AttributedString(label);
_hasBeenAnnotated = true; _hasBeenAnnotated = true;
} }
...@@ -4045,7 +4018,6 @@ class SemanticsConfiguration { ...@@ -4045,7 +4018,6 @@ class SemanticsConfiguration {
/// [value] will be after performing [SemanticsAction.decrease]. /// [value] will be after performing [SemanticsAction.decrease].
String get value => _attributedValue.string; String get value => _attributedValue.string;
set value(String value) { set value(String value) {
assert(value != null);
_attributedValue = AttributedString(value); _attributedValue = AttributedString(value);
_hasBeenAnnotated = true; _hasBeenAnnotated = true;
} }
...@@ -4091,7 +4063,6 @@ class SemanticsConfiguration { ...@@ -4091,7 +4063,6 @@ class SemanticsConfiguration {
/// * [attributedIncreasedValue], which is the [AttributedString] of this property. /// * [attributedIncreasedValue], which is the [AttributedString] of this property.
String get increasedValue => _attributedIncreasedValue.string; String get increasedValue => _attributedIncreasedValue.string;
set increasedValue(String increasedValue) { set increasedValue(String increasedValue) {
assert(increasedValue != null);
_attributedIncreasedValue = AttributedString(increasedValue); _attributedIncreasedValue = AttributedString(increasedValue);
_hasBeenAnnotated = true; _hasBeenAnnotated = true;
} }
...@@ -4129,7 +4100,6 @@ class SemanticsConfiguration { ...@@ -4129,7 +4100,6 @@ class SemanticsConfiguration {
/// * [attributedDecreasedValue], which is the [AttributedString] of this property. /// * [attributedDecreasedValue], which is the [AttributedString] of this property.
String get decreasedValue => _attributedDecreasedValue.string; String get decreasedValue => _attributedDecreasedValue.string;
set decreasedValue(String decreasedValue) { set decreasedValue(String decreasedValue) {
assert(decreasedValue != null);
_attributedDecreasedValue = AttributedString(decreasedValue); _attributedDecreasedValue = AttributedString(decreasedValue);
_hasBeenAnnotated = true; _hasBeenAnnotated = true;
} }
...@@ -4164,7 +4134,6 @@ class SemanticsConfiguration { ...@@ -4164,7 +4134,6 @@ class SemanticsConfiguration {
/// * [attributedHint], which is the [AttributedString] of this property. /// * [attributedHint], which is the [AttributedString] of this property.
String get hint => _attributedHint.string; String get hint => _attributedHint.string;
set hint(String hint) { set hint(String hint) {
assert(hint != null);
_attributedHint = AttributedString(hint); _attributedHint = AttributedString(hint);
_hasBeenAnnotated = true; _hasBeenAnnotated = true;
} }
...@@ -4217,7 +4186,7 @@ class SemanticsConfiguration { ...@@ -4217,7 +4186,7 @@ class SemanticsConfiguration {
double get elevation => _elevation; double get elevation => _elevation;
double _elevation = 0.0; double _elevation = 0.0;
set elevation(double value) { set elevation(double value) {
assert(value != null && value >= 0.0); assert(value >= 0.0);
if (value == _elevation) { if (value == _elevation) {
return; return;
} }
...@@ -4234,7 +4203,7 @@ class SemanticsConfiguration { ...@@ -4234,7 +4203,7 @@ class SemanticsConfiguration {
double get thickness => _thickness; double get thickness => _thickness;
double _thickness = 0.0; double _thickness = 0.0;
set thickness(double value) { set thickness(double value) {
assert(value != null && value >= 0.0); assert(value >= 0.0);
if (value == _thickness) { if (value == _thickness) {
return; return;
} }
...@@ -4632,7 +4601,7 @@ class SemanticsConfiguration { ...@@ -4632,7 +4601,7 @@ class SemanticsConfiguration {
if (_currentValueLength != null && other._currentValueLength != null) { if (_currentValueLength != null && other._currentValueLength != null) {
return false; return false;
} }
if (_attributedValue != null && _attributedValue.string.isNotEmpty && other._attributedValue != null && other._attributedValue.string.isNotEmpty) { if (_attributedValue.string.isNotEmpty && other._attributedValue.string.isNotEmpty) {
return false; return false;
} }
return true; return true;
...@@ -4680,13 +4649,13 @@ class SemanticsConfiguration { ...@@ -4680,13 +4649,13 @@ class SemanticsConfiguration {
otherAttributedString: child._attributedLabel, otherAttributedString: child._attributedLabel,
otherTextDirection: child.textDirection, otherTextDirection: child.textDirection,
); );
if (_attributedValue == null || _attributedValue.string == '') { if (_attributedValue.string == '') {
_attributedValue = child._attributedValue; _attributedValue = child._attributedValue;
} }
if (_attributedIncreasedValue == null || _attributedIncreasedValue.string == '') { if (_attributedIncreasedValue.string == '') {
_attributedIncreasedValue = child._attributedIncreasedValue; _attributedIncreasedValue = child._attributedIncreasedValue;
} }
if (_attributedDecreasedValue == null || _attributedDecreasedValue.string == '') { if (_attributedDecreasedValue.string == '') {
_attributedDecreasedValue = child._attributedDecreasedValue; _attributedDecreasedValue = child._attributedDecreasedValue;
} }
_attributedHint = _concatAttributedString( _attributedHint = _concatAttributedString(
...@@ -4880,8 +4849,7 @@ class OrdinalSortKey extends SemanticsSortKey { ...@@ -4880,8 +4849,7 @@ class OrdinalSortKey extends SemanticsSortKey {
const OrdinalSortKey( const OrdinalSortKey(
this.order, { this.order, {
super.name, super.name,
}) : assert(order != null), }) : assert(order > double.negativeInfinity),
assert(order > double.negativeInfinity),
assert(order < double.infinity); assert(order < double.infinity);
/// Determines the placement of this key in a sequence of keys that defines /// Determines the placement of this key in a sequence of keys that defines
...@@ -4894,7 +4862,7 @@ class OrdinalSortKey extends SemanticsSortKey { ...@@ -4894,7 +4862,7 @@ class OrdinalSortKey extends SemanticsSortKey {
@override @override
int doCompare(OrdinalSortKey other) { int doCompare(OrdinalSortKey other) {
if (other.order == null || order == null || other.order == order) { if (other.order == order) {
return 0; return 0;
} }
return order.compareTo(other.order); return order.compareTo(other.order);
......
...@@ -87,9 +87,7 @@ class AnnounceSemanticsEvent extends SemanticsEvent { ...@@ -87,9 +87,7 @@ class AnnounceSemanticsEvent extends SemanticsEvent {
/// Constructs an event that triggers an announcement by the platform. /// Constructs an event that triggers an announcement by the platform.
const AnnounceSemanticsEvent(this.message, this.textDirection, {this.assertiveness = Assertiveness.polite}) const AnnounceSemanticsEvent(this.message, this.textDirection, {this.assertiveness = Assertiveness.polite})
: assert(message != null), : super('announce');
assert(textDirection != null),
super('announce');
/// The message to announce. /// The message to announce.
/// ///
......
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