Unverified Commit d227788a authored by Konstantin Scheglov's avatar Konstantin Scheglov Committed by GitHub

Move assert(s) that reference 'this' to the constructor bodies. (#66914)

parent 5f76bfb4
...@@ -349,8 +349,9 @@ class CupertinoPageRoute<T> extends PageRoute<T> with CupertinoRouteTransitionMi ...@@ -349,8 +349,9 @@ class CupertinoPageRoute<T> extends PageRoute<T> with CupertinoRouteTransitionMi
}) : assert(builder != null), }) : assert(builder != null),
assert(maintainState != null), assert(maintainState != null),
assert(fullscreenDialog != null), assert(fullscreenDialog != null),
assert(opaque), super(settings: settings, fullscreenDialog: fullscreenDialog) {
super(settings: settings, fullscreenDialog: fullscreenDialog); assert(opaque);
}
/// Builds the primary contents of the route. /// Builds the primary contents of the route.
final WidgetBuilder builder; final WidgetBuilder builder;
...@@ -376,8 +377,9 @@ class _PageBasedCupertinoPageRoute<T> extends PageRoute<T> with CupertinoRouteTr ...@@ -376,8 +377,9 @@ class _PageBasedCupertinoPageRoute<T> extends PageRoute<T> with CupertinoRouteTr
_PageBasedCupertinoPageRoute({ _PageBasedCupertinoPageRoute({
required CupertinoPage<T> page, required CupertinoPage<T> page,
}) : assert(page != null), }) : assert(page != null),
assert(opaque), super(settings: page) {
super(settings: page); assert(opaque);
}
CupertinoPage<T> get _page => settings as CupertinoPage<T>; CupertinoPage<T> get _page => settings as CupertinoPage<T>;
......
...@@ -45,8 +45,9 @@ class MaterialPageRoute<T> extends PageRoute<T> with MaterialRouteTransitionMixi ...@@ -45,8 +45,9 @@ class MaterialPageRoute<T> extends PageRoute<T> with MaterialRouteTransitionMixi
}) : assert(builder != null), }) : assert(builder != null),
assert(maintainState != null), assert(maintainState != null),
assert(fullscreenDialog != null), assert(fullscreenDialog != null),
assert(opaque), super(settings: settings, fullscreenDialog: fullscreenDialog) {
super(settings: settings, fullscreenDialog: fullscreenDialog); assert(opaque);
}
/// Builds the primary contents of the route. /// Builds the primary contents of the route.
final WidgetBuilder builder; final WidgetBuilder builder;
...@@ -186,8 +187,9 @@ class _PageBasedMaterialPageRoute<T> extends PageRoute<T> with MaterialRouteTran ...@@ -186,8 +187,9 @@ class _PageBasedMaterialPageRoute<T> extends PageRoute<T> with MaterialRouteTran
_PageBasedMaterialPageRoute({ _PageBasedMaterialPageRoute({
@required MaterialPage<T> page, @required MaterialPage<T> page,
}) : assert(page != null), }) : assert(page != null),
assert(opaque), super(settings: page) {
super(settings: page); assert(opaque);
}
MaterialPage<T> get _page => settings as MaterialPage<T>; MaterialPage<T> get _page => settings as MaterialPage<T>;
......
...@@ -1918,19 +1918,20 @@ abstract class MultiChildRenderObjectWidget extends RenderObjectWidget { ...@@ -1918,19 +1918,20 @@ abstract class MultiChildRenderObjectWidget extends RenderObjectWidget {
/// objects. /// objects.
MultiChildRenderObjectWidget({ Key? key, this.children = const <Widget>[] }) MultiChildRenderObjectWidget({ Key? key, this.children = const <Widget>[] })
: assert(children != null), : assert(children != null),
assert(() { super(key: key) {
for (int index = 0; index < children.length; index++) { assert(() {
// TODO(a14n): remove this check to have a lot more const widget for (int index = 0; index < children.length; index++) {
if (children[index] == null) { // ignore: dead_code // TODO(a14n): remove this check to have a lot more const widget
throw FlutterError( if (children[index] == null) { // ignore: dead_code
throw FlutterError(
"$runtimeType's children must not contain any null values, " "$runtimeType's children must not contain any null values, "
'but a null value was found at index $index' 'but a null value was found at index $index'
); );
}
} }
return true; }
}()), // https://github.com/dart-lang/sdk/issues/29276 return true;
super(key: key); }()); // https://github.com/dart-lang/sdk/issues/29276
}
/// The widgets below this widget in the tree. /// The widgets below this widget in the tree.
/// ///
......
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