Commit 0b2fb132 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Add const non-null asserts where required (#9939)

Also fixes a small typo.
parent 4109e282
...@@ -100,6 +100,7 @@ class DragUpdateDetails { ...@@ -100,6 +100,7 @@ class DragUpdateDetails {
this.primaryDelta, this.primaryDelta,
@required this.globalPosition @required this.globalPosition
}) { }) {
assert(delta != null);
assert(primaryDelta == null assert(primaryDelta == null
|| (primaryDelta == delta.dx && delta.dy == 0.0) || (primaryDelta == delta.dx && delta.dy == 0.0)
|| (primaryDelta == delta.dy && delta.dx == 0.0)); || (primaryDelta == delta.dy && delta.dx == 0.0));
......
...@@ -13,7 +13,7 @@ class Velocity { ...@@ -13,7 +13,7 @@ class Velocity {
/// Creates a velocity. /// Creates a velocity.
/// ///
/// The [pixelsPerSecond] argument must not be null. /// The [pixelsPerSecond] argument must not be null.
const Velocity({ this.pixelsPerSecond }); const Velocity({ this.pixelsPerSecond }) : assert(pixelsPerSecond != null);
/// A velocity that isn't moving at all. /// A velocity that isn't moving at all.
static const Velocity zero = const Velocity(pixelsPerSecond: Offset.zero); static const Velocity zero = const Velocity(pixelsPerSecond: Offset.zero);
...@@ -87,12 +87,17 @@ class Velocity { ...@@ -87,12 +87,17 @@ class Velocity {
/// useful velocity operations. /// useful velocity operations.
class VelocityEstimate { class VelocityEstimate {
/// Creates a dimensional velocity estimate. /// Creates a dimensional velocity estimate.
///
/// [pixelsPerSecond], [confidence], [duration], and [offset] must not be null.
const VelocityEstimate({ const VelocityEstimate({
this.pixelsPerSecond, this.pixelsPerSecond,
this.confidence, this.confidence,
this.duration, this.duration,
this.offset, this.offset,
}); }) : assert(pixelsPerSecond != null),
assert(confidence != null),
assert(duration != null),
assert(offset != null);
/// The number of pixels per second of velocity in the x and y directions. /// The number of pixels per second of velocity in the x and y directions.
final Offset pixelsPerSecond; final Offset pixelsPerSecond;
...@@ -116,7 +121,9 @@ class VelocityEstimate { ...@@ -116,7 +121,9 @@ class VelocityEstimate {
} }
class _PointAtTime { class _PointAtTime {
const _PointAtTime(this.point, this.time); const _PointAtTime(this.point, this.time)
: assert(point != null),
assert(time != null);
final Duration time; final Duration time;
final Offset point; final Offset point;
......
...@@ -40,7 +40,7 @@ class DataColumn { ...@@ -40,7 +40,7 @@ class DataColumn {
this.tooltip, this.tooltip,
this.numeric: false, this.numeric: false,
this.onSort this.onSort
}); }) : assert(label != null);
/// The column heading. /// The column heading.
/// ///
...@@ -92,7 +92,7 @@ class DataRow { ...@@ -92,7 +92,7 @@ class DataRow {
this.selected: false, this.selected: false,
this.onSelectChanged, this.onSelectChanged,
this.cells this.cells
}); }) : assert(cells != null);
/// Creates the configuration for a row of a [DataTable], deriving /// Creates the configuration for a row of a [DataTable], deriving
/// the key from a row index. /// the key from a row index.
...@@ -103,7 +103,8 @@ class DataRow { ...@@ -103,7 +103,8 @@ class DataRow {
this.selected: false, this.selected: false,
this.onSelectChanged, this.onSelectChanged,
this.cells this.cells
}) : key = new ValueKey<int>(index); }) : assert(cells != null),
key = new ValueKey<int>(index);
/// A [Key] that uniquely identifies this row. This is used to /// A [Key] that uniquely identifies this row. This is used to
/// ensure that if a row is added or removed, any stateful widgets /// ensure that if a row is added or removed, any stateful widgets
...@@ -167,7 +168,7 @@ class DataCell { ...@@ -167,7 +168,7 @@ class DataCell {
this.placeholder: false, this.placeholder: false,
this.showEditIcon: false, this.showEditIcon: false,
this.onTap, this.onTap,
}); }) : assert(child != null);
/// A cell that has no content and has zero width and height. /// A cell that has no content and has zero width and height.
static final DataCell empty = new DataCell(new Container(width: 0.0, height: 0.0)); static final DataCell empty = new DataCell(new Container(width: 0.0, height: 0.0));
......
...@@ -69,7 +69,11 @@ class IconButton extends StatelessWidget { ...@@ -69,7 +69,11 @@ class IconButton extends StatelessWidget {
this.disabledColor, this.disabledColor,
@required this.onPressed, @required this.onPressed,
this.tooltip this.tooltip
}) : super(key: key); }) : assert(iconSize != null),
assert(padding != null),
assert(alignment != null),
assert(icon != null),
super(key: key);
/// The size of the icon inside the button. /// The size of the icon inside the button.
/// ///
......
...@@ -137,6 +137,7 @@ class ListTile extends StatelessWidget { ...@@ -137,6 +137,7 @@ class ListTile extends StatelessWidget {
}) : assert(isThreeLine != null), }) : assert(isThreeLine != null),
assert(enabled != null), assert(enabled != null),
assert(selected != null), assert(selected != null),
assert(!isThreeLine || subtitle != null),
super(key: key); super(key: key);
/// A widget to display before the title. /// A widget to display before the title.
......
...@@ -17,7 +17,7 @@ abstract class MergeableMaterialItem { ...@@ -17,7 +17,7 @@ abstract class MergeableMaterialItem {
/// const constructors so that they can be used in const expressions. /// const constructors so that they can be used in const expressions.
/// ///
/// The argument is the [key], which must not be null. /// The argument is the [key], which must not be null.
const MergeableMaterialItem(this.key); const MergeableMaterialItem(this.key) : assert(key != null);
/// The key for this item of the list. /// The key for this item of the list.
/// ///
......
...@@ -232,7 +232,8 @@ class DefaultTabController extends StatefulWidget { ...@@ -232,7 +232,8 @@ class DefaultTabController extends StatefulWidget {
@required this.length, @required this.length,
this.initialIndex: 0, this.initialIndex: 0,
@required this.child, @required this.child,
}) : super(key: key); }) : assert(initialIndex != null),
super(key: key);
/// The total number of tabs. Must be greater than one. /// The total number of tabs. Must be greater than one.
final int length; final int length;
......
...@@ -993,7 +993,7 @@ class LinearGradient extends Gradient { ...@@ -993,7 +993,7 @@ class LinearGradient extends Gradient {
/// * [CustomPainter], which shows how to use the above sample code in a custom /// * [CustomPainter], which shows how to use the above sample code in a custom
/// painter. /// painter.
class RadialGradient extends Gradient { class RadialGradient extends Gradient {
/// Creates a radial graident. /// Creates a radial gradient.
/// ///
/// The [colors] argument must not be null. If [stops] is non-null, it must /// The [colors] argument must not be null. If [stops] is non-null, it must
/// have the same length as [colors]. /// have the same length as [colors].
...@@ -1003,7 +1003,10 @@ class RadialGradient extends Gradient { ...@@ -1003,7 +1003,10 @@ class RadialGradient extends Gradient {
this.colors, this.colors,
this.stops, this.stops,
this.tileMode: TileMode.clamp, this.tileMode: TileMode.clamp,
}); }) : assert(center != null),
assert(radius != null),
assert(colors != null),
assert(tileMode != null);
/// The center of the gradient, as an offset into the unit square /// The center of the gradient, as an offset into the unit square
/// describing the gradient which will be mapped onto the paint box. /// describing the gradient which will be mapped onto the paint box.
...@@ -1265,7 +1268,7 @@ class DecorationImage { ...@@ -1265,7 +1268,7 @@ class DecorationImage {
this.centerSlice, this.centerSlice,
this.colorFilter, this.colorFilter,
this.alignment, this.alignment,
}); }) : assert(image != null);
/// The image to be painted into the decoration. /// The image to be painted into the decoration.
final ImageProvider image; final ImageProvider image;
......
...@@ -17,7 +17,11 @@ class HSVColor { ...@@ -17,7 +17,11 @@ class HSVColor {
/// ///
/// All the arguments must not be null and be in their respective ranges. See /// All the arguments must not be null and be in their respective ranges. See
/// the fields for each parameter for a description of their ranges. /// the fields for each parameter for a description of their ranges.
const HSVColor.fromAHSV(this.alpha, this.hue, this.saturation, this.value); const HSVColor.fromAHSV(this.alpha, this.hue, this.saturation, this.value)
: assert(alpha != null),
assert(hue != null),
assert(saturation != null),
assert(value != null);
/// Alpha, from 0.0 to 1.0. /// Alpha, from 0.0 to 1.0.
final double alpha; final double alpha;
......
...@@ -26,7 +26,7 @@ class TextStyle { ...@@ -26,7 +26,7 @@ class TextStyle {
this.decoration, this.decoration,
this.decorationColor, this.decorationColor,
this.decorationStyle this.decorationStyle
}); }) : assert(inherit != null);
/// Whether null values are replaced with their value in an ancestor text style (e.g., in a [TextSpan] tree). /// Whether null values are replaced with their value in an ancestor text style (e.g., in a [TextSpan] tree).
final bool inherit; final bool inherit;
......
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