diff --git a/packages/flutter/lib/src/animation/animations.dart b/packages/flutter/lib/src/animation/animations.dart index b321ace22a..852f42a5c3 100644 --- a/packages/flutter/lib/src/animation/animations.dart +++ b/packages/flutter/lib/src/animation/animations.dart @@ -439,14 +439,12 @@ class CurvedAnimation extends Animation with AnimationWithParentMixin[ - ErrorSummary('Invalid curve endpoint at $t.'), - ErrorDescription( - 'Curves must map 0.0 to near zero and 1.0 to near one but ' - '${activeCurve.runtimeType} mapped $t to $transformedValue, which ' - 'is near $roundedTransformedValue.' - ) - ]); + throw FlutterError( + 'Invalid curve endpoint at $t.\n' + 'Curves must map 0.0 to near zero and 1.0 to near one but ' + '${activeCurve.runtimeType} mapped $t to $transformedValue, which ' + 'is near $roundedTransformedValue.' + ); } return true; }()); diff --git a/packages/flutter/lib/src/cupertino/tab_view.dart b/packages/flutter/lib/src/cupertino/tab_view.dart index 37f5a034d0..65b84332fc 100644 --- a/packages/flutter/lib/src/cupertino/tab_view.dart +++ b/packages/flutter/lib/src/cupertino/tab_view.dart @@ -192,33 +192,29 @@ class _CupertinoTabViewState extends State { Route _onUnknownRoute(RouteSettings settings) { assert(() { if (widget.onUnknownRoute == null) { - throw FlutterError.fromParts([ - ErrorSummary('Could not find a generator for route $settings in the $runtimeType.'), - ErrorDescription( - 'Generators for routes are searched for in the following order:\n' - ' 1. For the "/" route, the "builder" property, if non-null, is used.\n' - ' 2. Otherwise, the "routes" table is used, if it has an entry for ' - 'the route.\n' - ' 3. Otherwise, onGenerateRoute is called. It should return a ' - 'non-null value for any valid route not handled by "builder" and "routes".\n' - ' 4. Finally if all else fails onUnknownRoute is called.\n' - 'Unfortunately, onUnknownRoute was not set.' - ) - ]); + throw FlutterError( + 'Could not find a generator for route $settings in the $runtimeType.\n' + 'Generators for routes are searched for in the following order:\n' + ' 1. For the "/" route, the "builder" property, if non-null, is used.\n' + ' 2. Otherwise, the "routes" table is used, if it has an entry for ' + 'the route.\n' + ' 3. Otherwise, onGenerateRoute is called. It should return a ' + 'non-null value for any valid route not handled by "builder" and "routes".\n' + ' 4. Finally if all else fails onUnknownRoute is called.\n' + 'Unfortunately, onUnknownRoute was not set.' + ); } return true; }()); final Route result = widget.onUnknownRoute(settings); assert(() { if (result == null) { - throw FlutterError.fromParts([ - ErrorSummary('The onUnknownRoute callback returned null.'), - ErrorDescription( - 'When the $runtimeType requested the route $settings from its ' - 'onUnknownRoute callback, the callback returned null. Such callbacks ' - 'must never return null.' - ) - ]); + throw FlutterError( + 'The onUnknownRoute callback returned null.\n' + 'When the $runtimeType requested the route $settings from its ' + 'onUnknownRoute callback, the callback returned null. Such callbacks ' + 'must never return null.' + ); } return true; }()); diff --git a/packages/flutter/lib/src/foundation/change_notifier.dart b/packages/flutter/lib/src/foundation/change_notifier.dart index 3f7cac30d8..c45aa2af24 100644 --- a/packages/flutter/lib/src/foundation/change_notifier.dart +++ b/packages/flutter/lib/src/foundation/change_notifier.dart @@ -102,10 +102,10 @@ class ChangeNotifier implements Listenable { bool _debugAssertNotDisposed() { assert(() { if (_listeners == null) { - throw FlutterError.fromParts([ - ErrorSummary('A $runtimeType was used after being disposed.'), - ErrorDescription('Once you have called dispose() on a $runtimeType, it can no longer be used.') - ]); + throw FlutterError( + 'A $runtimeType was used after being disposed.\n' + 'Once you have called dispose() on a $runtimeType, it can no longer be used.' + ); } return true; }()); diff --git a/packages/flutter/lib/src/material/page.dart b/packages/flutter/lib/src/material/page.dart index e97df68c79..b6314395b5 100644 --- a/packages/flutter/lib/src/material/page.dart +++ b/packages/flutter/lib/src/material/page.dart @@ -82,10 +82,10 @@ class MaterialPageRoute extends PageRoute { final Widget result = builder(context); assert(() { if (result == null) { - throw FlutterError.fromParts([ - ErrorSummary('The builder for route "${settings.name}" returned null.'), - ErrorDescription('Route builders must never return null.') - ]); + throw FlutterError( + 'The builder for route "${settings.name}" returned null.\n' + 'Route builders must never return null.' + ); } return true; }()); diff --git a/packages/flutter/lib/src/rendering/custom_layout.dart b/packages/flutter/lib/src/rendering/custom_layout.dart index 71dd11277d..ebb10751fc 100644 --- a/packages/flutter/lib/src/rendering/custom_layout.dart +++ b/packages/flutter/lib/src/rendering/custom_layout.dart @@ -142,16 +142,16 @@ abstract class MultiChildLayoutDelegate { final RenderBox child = _idToChild[childId]; assert(() { if (child == null) { - throw FlutterError.fromParts([ - ErrorSummary('The $this custom multichild layout delegate tried to lay out a non-existent child.'), - ErrorDescription('There is no child with the id "$childId".') - ]); + throw FlutterError( + 'The $this custom multichild layout delegate tried to lay out a non-existent child.\n' + 'There is no child with the id "$childId".' + ); } if (!_debugChildrenNeedingLayout.remove(child)) { - throw FlutterError.fromParts([ - ErrorSummary('The $this custom multichild layout delegate tried to lay out the child with id "$childId" more than once.'), - ErrorDescription('Each child must be laid out exactly once.') - ]); + throw FlutterError( + 'The $this custom multichild layout delegate tried to lay out the child with id "$childId" more than once.\n' + 'Each child must be laid out exactly once.' + ); } try { assert(constraints.debugAssertIsValid(isAppliedConstraint: true)); @@ -182,15 +182,15 @@ abstract class MultiChildLayoutDelegate { final RenderBox child = _idToChild[childId]; assert(() { if (child == null) { - throw FlutterError.fromParts([ - ErrorSummary('The $this custom multichild layout delegate tried to position out a non-existent child:'), - ErrorDescription('There is no child with the id "$childId".') - ]); + throw FlutterError( + 'The $this custom multichild layout delegate tried to position out a non-existent child:\n' + 'There is no child with the id "$childId".' + ); } if (offset == null) { - throw FlutterError.fromParts([ - ErrorSummary('The $this custom multichild layout delegate provided a null position for the child with id "$childId".') - ]); + throw FlutterError( + 'The $this custom multichild layout delegate provided a null position for the child with id "$childId".' + ); } return true; }()); diff --git a/packages/flutter/lib/src/rendering/flow.dart b/packages/flutter/lib/src/rendering/flow.dart index 15b1447931..7a53be1ee9 100644 --- a/packages/flutter/lib/src/rendering/flow.dart +++ b/packages/flutter/lib/src/rendering/flow.dart @@ -318,13 +318,11 @@ class RenderFlow extends RenderBox final FlowParentData childParentData = child.parentData as FlowParentData; assert(() { if (childParentData._transform != null) { - throw FlutterError.fromParts([ - ErrorSummary('Cannot call paintChild twice for the same child.'), - ErrorDescription( - 'The flow delegate of type ${_delegate.runtimeType} attempted to ' - 'paint child $i multiple times, which is not permitted.' - ) - ]); + throw FlutterError( + 'Cannot call paintChild twice for the same child.\n' + 'The flow delegate of type ${_delegate.runtimeType} attempted to ' + 'paint child $i multiple times, which is not permitted.' + ); } return true; }()); diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index 249f2eebe4..da754538b3 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -461,15 +461,13 @@ class RenderAspectRatio extends RenderProxyBox { assert(constraints.debugAssertIsValid()); assert(() { if (!constraints.hasBoundedWidth && !constraints.hasBoundedHeight) { - throw FlutterError.fromParts([ - ErrorSummary('$runtimeType has unbounded constraints.'), - ErrorDescription( - 'This $runtimeType was given an aspect ratio of $aspectRatio but was given ' - 'both unbounded width and unbounded height constraints. Because both ' - "constraints were unbounded, this render object doesn't know how much " - 'size to consume.' - ) - ]); + throw FlutterError( + '$runtimeType has unbounded constraints.\n' + 'This $runtimeType was given an aspect ratio of $aspectRatio but was given ' + 'both unbounded width and unbounded height constraints. Because both ' + 'constraints were unbounded, this render object doesn\'t know how much ' + 'size to consume.' + ); } return true; }()); diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index d4bdee62f4..fc01190ef9 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -1018,14 +1018,12 @@ class _WidgetsAppState extends State with WidgetsBindingObserver { final Route result = widget.onUnknownRoute(settings); assert(() { if (result == null) { - throw FlutterError.fromParts([ - ErrorSummary('The onUnknownRoute callback returned null.'), - ErrorDescription( - 'When the $runtimeType requested the route $settings from its ' - 'onUnknownRoute callback, the callback returned null. Such callbacks ' - 'must never return null.' - ) - ]); + throw FlutterError( + 'The onUnknownRoute callback returned null.\n' + 'When the $runtimeType requested the route $settings from its ' + 'onUnknownRoute callback, the callback returned null. Such callbacks ' + 'must never return null.' + ); } return true; }()); diff --git a/packages/flutter/lib/src/widgets/debug.dart b/packages/flutter/lib/src/widgets/debug.dart index e61374721e..94e2ea261d 100644 --- a/packages/flutter/lib/src/widgets/debug.dart +++ b/packages/flutter/lib/src/widgets/debug.dart @@ -136,13 +136,11 @@ bool debugChildrenHaveDuplicateKeys(Widget parent, Iterable children) { assert(() { final Key nonUniqueKey = _firstNonUniqueKey(children); if (nonUniqueKey != null) { - throw FlutterError.fromParts([ - ErrorSummary('Duplicate keys found.'), - ErrorDescription( - 'If multiple keyed nodes exist as children of another node, they must have unique keys.\n' - '$parent has multiple children with key $nonUniqueKey.' - ), - ]); + throw FlutterError( + 'Duplicate keys found.\n' + 'If multiple keyed nodes exist as children of another node, they must have unique keys.\n' + '$parent has multiple children with key $nonUniqueKey.' + ); } return true; }()); @@ -165,9 +163,7 @@ bool debugItemsHaveDuplicateKeys(Iterable items) { assert(() { final Key nonUniqueKey = _firstNonUniqueKey(items); if (nonUniqueKey != null) - throw FlutterError.fromParts([ - ErrorSummary('Duplicate key found: $nonUniqueKey.'), - ]); + throw FlutterError('Duplicate key found: $nonUniqueKey.'); return true; }()); return false; @@ -315,7 +311,7 @@ bool debugAssertAllWidgetVarsUnset(String reason) { debugPrintGlobalKeyedWidgetLifecycle || debugProfileBuildsEnabled || debugHighlightDeprecatedWidgets) { - throw FlutterError.fromParts([ErrorSummary(reason)]); + throw FlutterError(reason); } return true; }()); diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index fdae25fee9..880527daf5 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -190,7 +190,7 @@ class TextEditingController extends ValueNotifier { /// change the controller's [value]. set selection(TextSelection newSelection) { if (newSelection.start > text.length || newSelection.end > text.length) - throw FlutterError.fromParts([ErrorSummary('invalid text selection: $newSelection')]); + throw FlutterError('invalid text selection: $newSelection'); value = value.copyWith(selection: newSelection, composing: TextRange.empty); } diff --git a/packages/flutter/lib/src/widgets/gesture_detector.dart b/packages/flutter/lib/src/widgets/gesture_detector.dart index 313b9958df..ac7bb6fb92 100644 --- a/packages/flutter/lib/src/widgets/gesture_detector.dart +++ b/packages/flutter/lib/src/widgets/gesture_detector.dart @@ -242,13 +242,11 @@ class GestureDetector extends StatelessWidget { } final String recognizer = havePan ? 'pan' : 'scale'; if (haveVerticalDrag && haveHorizontalDrag) { - throw FlutterError.fromParts([ - ErrorSummary('Incorrect GestureDetector arguments.'), - ErrorDescription( - 'Simultaneously having a vertical drag gesture recognizer, a horizontal drag gesture recognizer, and a $recognizer gesture recognizer ' - 'will result in the $recognizer gesture recognizer being ignored, since the other two will catch all drags.' - ) - ]); + throw FlutterError( + 'Incorrect GestureDetector arguments.\n' + 'Simultaneously having a vertical drag gesture recognizer, a horizontal drag gesture recognizer, and a $recognizer gesture recognizer ' + 'will result in the $recognizer gesture recognizer being ignored, since the other two will catch all drags.' + ); } } return true; diff --git a/packages/flutter/lib/src/widgets/scroll_position.dart b/packages/flutter/lib/src/widgets/scroll_position.dart index 89ae779abb..00c28a6fe7 100644 --- a/packages/flutter/lib/src/widgets/scroll_position.dart +++ b/packages/flutter/lib/src/widgets/scroll_position.dart @@ -229,14 +229,12 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { assert(() { final double delta = newPixels - pixels; if (overscroll.abs() > delta.abs()) { - throw FlutterError.fromParts([ - ErrorSummary('$runtimeType.applyBoundaryConditions returned invalid overscroll value.'), - ErrorDescription( - 'setPixels() was called to change the scroll offset from $pixels to $newPixels.\n' - 'That is a delta of $delta units.\n' - '$runtimeType.applyBoundaryConditions reported an overscroll of $overscroll units.' - ) - ]); + throw FlutterError( + '$runtimeType.applyBoundaryConditions returned invalid overscroll value.\n' + 'setPixels() was called to change the scroll offset from $pixels to $newPixels.\n' + 'That is a delta of $delta units.\n' + '$runtimeType.applyBoundaryConditions reported an overscroll of $overscroll units.' + ); } return true; }()); @@ -402,18 +400,16 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { assert(() { final double delta = value - pixels; if (result.abs() > delta.abs()) { - throw FlutterError.fromParts([ - ErrorSummary('${physics.runtimeType}.applyBoundaryConditions returned invalid overscroll value.'), - ErrorDescription( - 'The method was called to consider a change from $pixels to $value, which is a ' - 'delta of ${delta.toStringAsFixed(1)} units. However, it returned an overscroll of ' - '${result.toStringAsFixed(1)} units, which has a greater magnitude than the delta. ' - 'The applyBoundaryConditions method is only supposed to reduce the possible range ' - 'of movement, not increase it.\n' - 'The scroll extents are $minScrollExtent .. $maxScrollExtent, and the ' - 'viewport dimension is $viewportDimension.' - ) - ]); + throw FlutterError( + '${physics.runtimeType}.applyBoundaryConditions returned invalid overscroll value.\n' + 'The method was called to consider a change from $pixels to $value, which is a ' + 'delta of ${delta.toStringAsFixed(1)} units. However, it returned an overscroll of ' + '${result.toStringAsFixed(1)} units, which has a greater magnitude than the delta. ' + 'The applyBoundaryConditions method is only supposed to reduce the possible range ' + 'of movement, not increase it.\n' + 'The scroll extents are $minScrollExtent .. $maxScrollExtent, and the ' + 'viewport dimension is $viewportDimension.' + ); } return true; }()); diff --git a/packages/flutter_test/lib/src/widget_tester.dart b/packages/flutter_test/lib/src/widget_tester.dart index 558064c490..4cd2a38ef4 100644 --- a/packages/flutter_test/lib/src/widget_tester.dart +++ b/packages/flutter_test/lib/src/widget_tester.dart @@ -780,8 +780,6 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker void _verifySemanticsHandlesWereDisposed() { assert(_lastRecordedSemanticsHandles != null); if (binding.pipelineOwner.debugOutstandingSemanticsHandles > _lastRecordedSemanticsHandles) { - // TODO(jacobr): The hint for this one causes a change in line breaks but - // I think it is for the best. throw FlutterError.fromParts([ ErrorSummary('A SemanticsHandle was active at the end of the test.'), ErrorDescription(