forked from firka/flutter
Add const non-null asserts where required (#9939)
Also fixes a small typo.
This commit is contained in:
@@ -100,6 +100,7 @@ class DragUpdateDetails {
|
||||
this.primaryDelta,
|
||||
@required this.globalPosition
|
||||
}) {
|
||||
assert(delta != null);
|
||||
assert(primaryDelta == null
|
||||
|| (primaryDelta == delta.dx && delta.dy == 0.0)
|
||||
|| (primaryDelta == delta.dy && delta.dx == 0.0));
|
||||
|
||||
@@ -13,7 +13,7 @@ class Velocity {
|
||||
/// Creates a velocity.
|
||||
///
|
||||
/// 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.
|
||||
static const Velocity zero = const Velocity(pixelsPerSecond: Offset.zero);
|
||||
@@ -87,12 +87,17 @@ class Velocity {
|
||||
/// useful velocity operations.
|
||||
class VelocityEstimate {
|
||||
/// Creates a dimensional velocity estimate.
|
||||
///
|
||||
/// [pixelsPerSecond], [confidence], [duration], and [offset] must not be null.
|
||||
const VelocityEstimate({
|
||||
this.pixelsPerSecond,
|
||||
this.confidence,
|
||||
this.duration,
|
||||
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.
|
||||
final Offset pixelsPerSecond;
|
||||
@@ -116,7 +121,9 @@ class VelocityEstimate {
|
||||
}
|
||||
|
||||
class _PointAtTime {
|
||||
const _PointAtTime(this.point, this.time);
|
||||
const _PointAtTime(this.point, this.time)
|
||||
: assert(point != null),
|
||||
assert(time != null);
|
||||
|
||||
final Duration time;
|
||||
final Offset point;
|
||||
|
||||
@@ -40,7 +40,7 @@ class DataColumn {
|
||||
this.tooltip,
|
||||
this.numeric: false,
|
||||
this.onSort
|
||||
});
|
||||
}) : assert(label != null);
|
||||
|
||||
/// The column heading.
|
||||
///
|
||||
@@ -92,7 +92,7 @@ class DataRow {
|
||||
this.selected: false,
|
||||
this.onSelectChanged,
|
||||
this.cells
|
||||
});
|
||||
}) : assert(cells != null);
|
||||
|
||||
/// Creates the configuration for a row of a [DataTable], deriving
|
||||
/// the key from a row index.
|
||||
@@ -103,7 +103,8 @@ class DataRow {
|
||||
this.selected: false,
|
||||
this.onSelectChanged,
|
||||
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
|
||||
/// ensure that if a row is added or removed, any stateful widgets
|
||||
@@ -167,7 +168,7 @@ class DataCell {
|
||||
this.placeholder: false,
|
||||
this.showEditIcon: false,
|
||||
this.onTap,
|
||||
});
|
||||
}) : assert(child != null);
|
||||
|
||||
/// 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));
|
||||
|
||||
@@ -69,7 +69,11 @@ class IconButton extends StatelessWidget {
|
||||
this.disabledColor,
|
||||
@required this.onPressed,
|
||||
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.
|
||||
///
|
||||
|
||||
@@ -137,6 +137,7 @@ class ListTile extends StatelessWidget {
|
||||
}) : assert(isThreeLine != null),
|
||||
assert(enabled != null),
|
||||
assert(selected != null),
|
||||
assert(!isThreeLine || subtitle != null),
|
||||
super(key: key);
|
||||
|
||||
/// A widget to display before the title.
|
||||
|
||||
@@ -17,7 +17,7 @@ abstract class MergeableMaterialItem {
|
||||
/// const constructors so that they can be used in const expressions.
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
|
||||
@@ -232,7 +232,8 @@ class DefaultTabController extends StatefulWidget {
|
||||
@required this.length,
|
||||
this.initialIndex: 0,
|
||||
@required this.child,
|
||||
}) : super(key: key);
|
||||
}) : assert(initialIndex != null),
|
||||
super(key: key);
|
||||
|
||||
/// The total number of tabs. Must be greater than one.
|
||||
final int length;
|
||||
|
||||
@@ -993,7 +993,7 @@ class LinearGradient extends Gradient {
|
||||
/// * [CustomPainter], which shows how to use the above sample code in a custom
|
||||
/// painter.
|
||||
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
|
||||
/// have the same length as [colors].
|
||||
@@ -1003,7 +1003,10 @@ class RadialGradient extends Gradient {
|
||||
this.colors,
|
||||
this.stops,
|
||||
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
|
||||
/// describing the gradient which will be mapped onto the paint box.
|
||||
@@ -1265,7 +1268,7 @@ class DecorationImage {
|
||||
this.centerSlice,
|
||||
this.colorFilter,
|
||||
this.alignment,
|
||||
});
|
||||
}) : assert(image != null);
|
||||
|
||||
/// The image to be painted into the decoration.
|
||||
final ImageProvider image;
|
||||
|
||||
@@ -17,7 +17,11 @@ class HSVColor {
|
||||
///
|
||||
/// 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.
|
||||
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.
|
||||
final double alpha;
|
||||
|
||||
@@ -26,7 +26,7 @@ class TextStyle {
|
||||
this.decoration,
|
||||
this.decorationColor,
|
||||
this.decorationStyle
|
||||
});
|
||||
}) : assert(inherit != null);
|
||||
|
||||
/// Whether null values are replaced with their value in an ancestor text style (e.g., in a [TextSpan] tree).
|
||||
final bool inherit;
|
||||
|
||||
Reference in New Issue
Block a user