Commit 7e3bef11 authored by Hixie's avatar Hixie

Replace WidgetError and RenderingError with FlutterError

parent 5a141172
...@@ -11,7 +11,7 @@ bool debugCheckHasMaterial(BuildContext context) { ...@@ -11,7 +11,7 @@ bool debugCheckHasMaterial(BuildContext context) {
assert(() { assert(() {
if (context.widget is! Material && context.ancestorWidgetOfExactType(Material) == null) { if (context.widget is! Material && context.ancestorWidgetOfExactType(Material) == null) {
Element element = context; Element element = context;
throw new WidgetError( throw new FlutterError(
'No Material widget found.\n' 'No Material widget found.\n'
'${context.widget.runtimeType} widgets require a Material widget ancestor.\n' '${context.widget.runtimeType} widgets require a Material widget ancestor.\n'
'In material design, most widgets are conceptually "printed" on a sheet of material. In Flutter\'s material library, ' 'In material design, most widgets are conceptually "printed" on a sheet of material. In Flutter\'s material library, '
...@@ -35,7 +35,7 @@ bool debugCheckHasScaffold(BuildContext context) { ...@@ -35,7 +35,7 @@ bool debugCheckHasScaffold(BuildContext context) {
assert(() { assert(() {
if (Scaffold.of(context) == null) { if (Scaffold.of(context) == null) {
Element element = context; Element element = context;
throw new WidgetError( throw new FlutterError(
'No Scaffold widget found.\n' 'No Scaffold widget found.\n'
'${context.widget.runtimeType} widgets require a Scaffold widget ancestor.\n' '${context.widget.runtimeType} widgets require a Scaffold widget ancestor.\n'
'The specific widget that could not find a Scaffold ancestor was:\n' 'The specific widget that could not find a Scaffold ancestor was:\n'
......
...@@ -306,17 +306,17 @@ class BoxConstraints extends Constraints { ...@@ -306,17 +306,17 @@ class BoxConstraints extends Constraints {
bool get debugAssertIsNormalized { bool get debugAssertIsNormalized {
assert(() { assert(() {
if (minWidth < 0.0 && minHeight < 0.0) if (minWidth < 0.0 && minHeight < 0.0)
throw new RenderingError('BoxConstraints has both a negative minimum width and a negative minimum height.\n$this'); throw new FlutterError('BoxConstraints has both a negative minimum width and a negative minimum height.\n$this');
if (minWidth < 0.0) if (minWidth < 0.0)
throw new RenderingError('BoxConstraints has a negative minimum width.\n$this'); throw new FlutterError('BoxConstraints has a negative minimum width.\n$this');
if (minHeight < 0.0) if (minHeight < 0.0)
throw new RenderingError('BoxConstraints has a negative minimum height.\n$this'); throw new FlutterError('BoxConstraints has a negative minimum height.\n$this');
if (maxWidth < minWidth && maxHeight < minHeight) if (maxWidth < minWidth && maxHeight < minHeight)
throw new RenderingError('BoxConstraints has both width and height constraints non-normalized.\n$this'); throw new FlutterError('BoxConstraints has both width and height constraints non-normalized.\n$this');
if (maxWidth < minWidth) if (maxWidth < minWidth)
throw new RenderingError('BoxConstraints has non-normalized width constraints.\n$this'); throw new FlutterError('BoxConstraints has non-normalized width constraints.\n$this');
if (maxHeight < minHeight) if (maxHeight < minHeight)
throw new RenderingError('BoxConstraints has non-normalized height constraints.\n$this'); throw new FlutterError('BoxConstraints has non-normalized height constraints.\n$this');
return isNormalized; return isNormalized;
}); });
return isNormalized; return isNormalized;
...@@ -636,7 +636,7 @@ abstract class RenderBox extends RenderObject { ...@@ -636,7 +636,7 @@ abstract class RenderBox extends RenderObject {
for (String line in description) for (String line in description)
information.writeln(' $line'); information.writeln(' $line');
} }
throw new RenderingError( throw new FlutterError(
'$runtimeType object was given an infinite size during layout.\n' '$runtimeType object was given an infinite size during layout.\n'
'This probably means that it is a render object that tries to be\n' 'This probably means that it is a render object that tries to be\n'
'as big as possible, but it was put inside another render object\n' 'as big as possible, but it was put inside another render object\n'
...@@ -647,7 +647,7 @@ abstract class RenderBox extends RenderObject { ...@@ -647,7 +647,7 @@ abstract class RenderBox extends RenderObject {
} }
// verify that the size is within the constraints // verify that the size is within the constraints
if (!constraints.isSatisfiedBy(_size)) { if (!constraints.isSatisfiedBy(_size)) {
throw new RenderingError( throw new FlutterError(
'$runtimeType does not meet its constraints.\n' '$runtimeType does not meet its constraints.\n'
'Constraints: $constraints\n' 'Constraints: $constraints\n'
'Size: $_size\n' 'Size: $_size\n'
...@@ -684,7 +684,7 @@ abstract class RenderBox extends RenderObject { ...@@ -684,7 +684,7 @@ abstract class RenderBox extends RenderObject {
RenderObject.debugCheckingIntrinsics = false; RenderObject.debugCheckingIntrinsics = false;
if (failures.isNotEmpty) { if (failures.isNotEmpty) {
assert(failureCount > 0); assert(failureCount > 0);
throw new RenderingError( throw new FlutterError(
'The intrinsic dimension methods of the $runtimeType class returned values that violate the given constraints.\n' 'The intrinsic dimension methods of the $runtimeType class returned values that violate the given constraints.\n'
'The constraints were: $constraints\n' 'The constraints were: $constraints\n'
'The following method${failureCount > 1 ? "s" : ""} returned values outside of those constraints:\n' 'The following method${failureCount > 1 ? "s" : ""} returned values outside of those constraints:\n'
......
...@@ -45,13 +45,13 @@ abstract class MultiChildLayoutDelegate { ...@@ -45,13 +45,13 @@ abstract class MultiChildLayoutDelegate {
final RenderBox child = _idToChild[childId]; final RenderBox child = _idToChild[childId];
assert(() { assert(() {
if (child == null) { if (child == null) {
throw new RenderingError( throw new FlutterError(
'The $this custom multichild layout delegate tried to lay out a non-existent child:\n' 'The $this custom multichild layout delegate tried to lay out a non-existent child:\n'
'There is no child with the id "$childId".' 'There is no child with the id "$childId".'
); );
} }
if (!_debugChildrenNeedingLayout.remove(child)) { if (!_debugChildrenNeedingLayout.remove(child)) {
throw new RenderingError( throw new FlutterError(
'The $this custom multichild layout delegate tried to lay out the child with id "$childId" more than once.\n' '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.' 'Each child must be laid out exactly once.'
); );
...@@ -59,7 +59,7 @@ abstract class MultiChildLayoutDelegate { ...@@ -59,7 +59,7 @@ abstract class MultiChildLayoutDelegate {
try { try {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsNormalized);
} on AssertionError catch (exception) { } on AssertionError catch (exception) {
throw new RenderingError( throw new FlutterError(
'The $this custom multichild layout delegate provided invalid box constraints for the child with id "$childId":\n' 'The $this custom multichild layout delegate provided invalid box constraints for the child with id "$childId":\n'
'$exception\n' '$exception\n'
'The minimum width and height must be greater than or equal to zero.\n' 'The minimum width and height must be greater than or equal to zero.\n'
...@@ -83,13 +83,13 @@ abstract class MultiChildLayoutDelegate { ...@@ -83,13 +83,13 @@ abstract class MultiChildLayoutDelegate {
final RenderBox child = _idToChild[childId]; final RenderBox child = _idToChild[childId];
assert(() { assert(() {
if (child == null) { if (child == null) {
throw new RenderingError( throw new FlutterError(
'The $this custom multichild layout delegate tried to position out a non-existent child:\n' 'The $this custom multichild layout delegate tried to position out a non-existent child:\n'
'There is no child with the id "$childId".' 'There is no child with the id "$childId".'
); );
} }
if (offset == null) { if (offset == null) {
throw new RenderingError( throw new FlutterError(
'The $this custom multichild layout delegate provided a null position for the child with id "$childId".' 'The $this custom multichild layout delegate provided a null position for the child with id "$childId".'
); );
} }
...@@ -124,7 +124,7 @@ abstract class MultiChildLayoutDelegate { ...@@ -124,7 +124,7 @@ abstract class MultiChildLayoutDelegate {
final MultiChildLayoutParentData childParentData = child.parentData; final MultiChildLayoutParentData childParentData = child.parentData;
assert(() { assert(() {
if (childParentData.id == null) { if (childParentData.id == null) {
throw new RenderingError( throw new FlutterError(
'The following child has no ID:\n' 'The following child has no ID:\n'
' $child\n' ' $child\n'
'Every child of a RenderCustomMultiChildLayoutBox must have an ID in its parent data.' 'Every child of a RenderCustomMultiChildLayoutBox must have an ID in its parent data.'
...@@ -143,13 +143,13 @@ abstract class MultiChildLayoutDelegate { ...@@ -143,13 +143,13 @@ abstract class MultiChildLayoutDelegate {
assert(() { assert(() {
if (_debugChildrenNeedingLayout.isNotEmpty) { if (_debugChildrenNeedingLayout.isNotEmpty) {
if (_debugChildrenNeedingLayout.length > 1) { if (_debugChildrenNeedingLayout.length > 1) {
throw new RenderingError( throw new FlutterError(
'The $this custom multichild layout delegate forgot to lay out the following children:\n' 'The $this custom multichild layout delegate forgot to lay out the following children:\n'
' ${_debugChildrenNeedingLayout.map(_debugDescribeChild).join("\n ")}\n' ' ${_debugChildrenNeedingLayout.map(_debugDescribeChild).join("\n ")}\n'
'Each child must be laid out exactly once.' 'Each child must be laid out exactly once.'
); );
} else { } else {
throw new RenderingError( throw new FlutterError(
'The $this custom multichild layout delegate forgot to lay out the following child:\n' 'The $this custom multichild layout delegate forgot to lay out the following child:\n'
' ${_debugDescribeChild(_debugChildrenNeedingLayout.single)}\n' ' ${_debugDescribeChild(_debugChildrenNeedingLayout.single)}\n'
'Each child must be laid out exactly once.' 'Each child must be laid out exactly once.'
......
...@@ -399,7 +399,7 @@ class RenderGrid extends RenderVirtualViewport<GridParentData> { ...@@ -399,7 +399,7 @@ class RenderGrid extends RenderVirtualViewport<GridParentData> {
void set mainAxis(Axis value) { void set mainAxis(Axis value) {
assert(() { assert(() {
if (value != Axis.vertical) if (value != Axis.vertical)
throw new RenderingError('RenderGrid doesn\'t yet support horizontal scrolling.'); throw new FlutterError('RenderGrid doesn\'t yet support horizontal scrolling.');
return true; return true;
}); });
super.mainAxis = value; super.mainAxis = value;
......
...@@ -20,6 +20,7 @@ import 'binding.dart'; ...@@ -20,6 +20,7 @@ import 'binding.dart';
export 'package:flutter/gestures.dart' show HitTestEntry, HitTestResult; export 'package:flutter/gestures.dart' show HitTestEntry, HitTestResult;
export 'package:flutter/painting.dart'; export 'package:flutter/painting.dart';
export 'package:flutter/services.dart' show FlutterError;
/// Base class for data associated with a [RenderObject] by its parent. /// Base class for data associated with a [RenderObject] by its parent.
/// ///
...@@ -2089,13 +2090,3 @@ abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent ...@@ -2089,13 +2090,3 @@ abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent
return result; return result;
} }
} }
/// Error thrown when the rendering library encounters a contract violation.
class RenderingError extends AssertionError {
RenderingError(this.message);
final String message;
@override
String toString() => message;
}
...@@ -441,7 +441,7 @@ class RenderAspectRatio extends RenderProxyBox { ...@@ -441,7 +441,7 @@ class RenderAspectRatio extends RenderProxyBox {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsNormalized);
assert(() { assert(() {
if (!constraints.hasBoundedWidth && !constraints.hasBoundedHeight) { if (!constraints.hasBoundedWidth && !constraints.hasBoundedHeight) {
throw new RenderingError( throw new FlutterError(
'$runtimeType has unbounded constraints.\n' '$runtimeType has unbounded constraints.\n'
'This $runtimeType was given an aspect ratio of $aspectRatio but was given ' 'This $runtimeType was given an aspect ratio of $aspectRatio but was given '
'both unbounded width and unbounded height constraints. Because both ' 'both unbounded width and unbounded height constraints. Because both '
...@@ -1386,7 +1386,7 @@ class RenderCustomPaint extends RenderProxyBox { ...@@ -1386,7 +1386,7 @@ class RenderCustomPaint extends RenderProxyBox {
// below that number. // below that number.
int debugNewCanvasSaveCount = canvas.getSaveCount(); int debugNewCanvasSaveCount = canvas.getSaveCount();
if (debugNewCanvasSaveCount > debugPreviousCanvasSaveCount) { if (debugNewCanvasSaveCount > debugPreviousCanvasSaveCount) {
throw new RenderingError( throw new FlutterError(
'The $painter custom painter called canvas.save() or canvas.saveLayer() at least ' 'The $painter custom painter called canvas.save() or canvas.saveLayer() at least '
'${debugNewCanvasSaveCount - debugPreviousCanvasSaveCount} more ' '${debugNewCanvasSaveCount - debugPreviousCanvasSaveCount} more '
'time${debugNewCanvasSaveCount - debugPreviousCanvasSaveCount == 1 ? '' : 's' } ' 'time${debugNewCanvasSaveCount - debugPreviousCanvasSaveCount == 1 ? '' : 's' } '
...@@ -1396,7 +1396,7 @@ class RenderCustomPaint extends RenderProxyBox { ...@@ -1396,7 +1396,7 @@ class RenderCustomPaint extends RenderProxyBox {
); );
} }
if (debugNewCanvasSaveCount < debugPreviousCanvasSaveCount) { if (debugNewCanvasSaveCount < debugPreviousCanvasSaveCount) {
throw new RenderingError( throw new FlutterError(
'The $painter custom painter called canvas.restore() ' 'The $painter custom painter called canvas.restore() '
'${debugPreviousCanvasSaveCount - debugNewCanvasSaveCount} more ' '${debugPreviousCanvasSaveCount - debugNewCanvasSaveCount} more '
'time${debugPreviousCanvasSaveCount - debugNewCanvasSaveCount == 1 ? '' : 's' } ' 'time${debugPreviousCanvasSaveCount - debugNewCanvasSaveCount == 1 ? '' : 's' } '
......
...@@ -2,9 +2,32 @@ ...@@ -2,9 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
/// Error class used to report Flutter-specific assertion failures and
/// contract violations.
class FlutterError extends AssertionError { class FlutterError extends AssertionError {
/// Creates a [FlutterError].
///
/// See [message] for details on the format that the message should
/// take.
///
/// Include as much detail as possible in the full error message,
/// including specifics about the state of the app that might be
/// relevant to debugging the error.
FlutterError(this.message); FlutterError(this.message);
/// The message associated with this error.
///
/// The message may have newlines in it. The first line should be a
/// terse description of the error, e.g. "Incorrect GlobalKey usage"
/// or "setState() or markNeedsBuild() called during build".
/// Subsequent lines can then contain more information. In some
/// cases, when a FlutterError is reported to the user, only the
/// first line is included. For example, Flutter will typically only
/// fully report the first exception at runtime, displaying only the
/// first line of subsequent errors.
///
/// All sentences in the error should be correctly punctuated (i.e.,
/// do end the error message with a period).
final String message; final String message;
@override @override
......
...@@ -291,7 +291,7 @@ class _DismissableState extends State<Dismissable> { ...@@ -291,7 +291,7 @@ class _DismissableState extends State<Dismissable> {
assert(() { assert(() {
if (_resizeAnimation.status != AnimationStatus.forward) { if (_resizeAnimation.status != AnimationStatus.forward) {
assert(_resizeAnimation.status == AnimationStatus.completed); assert(_resizeAnimation.status == AnimationStatus.completed);
throw new WidgetError( throw new FlutterError(
'A dismissed Dismissable widget is still part of the tree.\n' + 'A dismissed Dismissable widget is still part of the tree.\n' +
'Make sure to implement the onDismissed handler and to immediately remove the Dismissable\n' + 'Make sure to implement the onDismissed handler and to immediately remove the Dismissable\n' +
'widget from the application once that handler has fired.' 'widget from the application once that handler has fired.'
......
...@@ -9,6 +9,7 @@ import 'package:flutter/rendering.dart'; ...@@ -9,6 +9,7 @@ import 'package:flutter/rendering.dart';
export 'dart:ui' show hashValues, hashList; export 'dart:ui' show hashValues, hashList;
export 'package:flutter/rendering.dart' show RenderObject, RenderBox, debugPrint; export 'package:flutter/rendering.dart' show RenderObject, RenderBox, debugPrint;
export 'package:flutter/services.dart' show FlutterError;
// KEYS // KEYS
...@@ -178,7 +179,7 @@ abstract class GlobalKey<T extends State<StatefulWidget>> extends Key { ...@@ -178,7 +179,7 @@ abstract class GlobalKey<T extends State<StatefulWidget>> extends Key {
message += 'The most recently registered instance is: ${_registry[key]}\n'; message += 'The most recently registered instance is: ${_registry[key]}\n';
} }
if (_debugDuplicates.isNotEmpty) { if (_debugDuplicates.isNotEmpty) {
throw new WidgetError( throw new FlutterError(
'Incorrect GlobalKey usage.\n' 'Incorrect GlobalKey usage.\n'
'$message' '$message'
); );
...@@ -380,7 +381,7 @@ abstract class State<T extends StatefulWidget> { ...@@ -380,7 +381,7 @@ abstract class State<T extends StatefulWidget> {
void setState(VoidCallback fn) { void setState(VoidCallback fn) {
assert(() { assert(() {
if (_debugLifecycleState == _StateLifecycle.defunct) { if (_debugLifecycleState == _StateLifecycle.defunct) {
throw new WidgetError( throw new FlutterError(
'setState() called after dipose(): $this\n' 'setState() called after dipose(): $this\n'
'This error happens if you call setState() on State object for a widget that\n' 'This error happens if you call setState() on State object for a widget that\n'
'no longer appears in the widget tree (e.g., whose parent widget no longer\n' 'no longer appears in the widget tree (e.g., whose parent widget no longer\n'
...@@ -1197,7 +1198,7 @@ abstract class BuildableElement extends Element { ...@@ -1197,7 +1198,7 @@ abstract class BuildableElement extends Element {
return true; return true;
} }
if (_debugStateLocked && (!_debugAllowIgnoredCallsToMarkNeedsBuild || !dirty)) { if (_debugStateLocked && (!_debugAllowIgnoredCallsToMarkNeedsBuild || !dirty)) {
throw new WidgetError( throw new FlutterError(
'setState() or markNeedsBuild() called during build.\n' 'setState() or markNeedsBuild() called during build.\n'
'This widget cannot be marked as needing to build because the framework ' 'This widget cannot be marked as needing to build because the framework '
'is already in the process of building widgets. A widget can be marked as ' 'is already in the process of building widgets. A widget can be marked as '
...@@ -1296,7 +1297,7 @@ abstract class ComponentElement extends BuildableElement { ...@@ -1296,7 +1297,7 @@ abstract class ComponentElement extends BuildableElement {
built = _builder(this); built = _builder(this);
assert(() { assert(() {
if (built == null) { if (built == null) {
throw new WidgetError( throw new FlutterError(
'A build function returned null.\n' 'A build function returned null.\n'
'The offending widget is: $widget\n' 'The offending widget is: $widget\n'
'Build functions must never return null. ' 'Build functions must never return null. '
...@@ -1388,7 +1389,7 @@ class StatefulElement extends ComponentElement { ...@@ -1388,7 +1389,7 @@ class StatefulElement extends ComponentElement {
assert(() { assert(() {
if (_state._debugLifecycleState == _StateLifecycle.initialized) if (_state._debugLifecycleState == _StateLifecycle.initialized)
return true; return true;
throw new WidgetError( throw new FlutterError(
'${_state.runtimeType}.initState failed to call super.initState.\n' '${_state.runtimeType}.initState failed to call super.initState.\n'
'initState() implementations must always call their superclass initState() method, to ensure ' 'initState() implementations must always call their superclass initState() method, to ensure '
'that the entire widget is initialized correctly.' 'that the entire widget is initialized correctly.'
...@@ -1430,7 +1431,7 @@ class StatefulElement extends ComponentElement { ...@@ -1430,7 +1431,7 @@ class StatefulElement extends ComponentElement {
assert(() { assert(() {
if (_state._debugLifecycleState == _StateLifecycle.defunct) if (_state._debugLifecycleState == _StateLifecycle.defunct)
return true; return true;
throw new WidgetError( throw new FlutterError(
'${_state.runtimeType}.dispose failed to call super.dispose.\n' '${_state.runtimeType}.dispose failed to call super.dispose.\n'
'dispose() implementations must always call their superclass dispose() method, to ensure ' 'dispose() implementations must always call their superclass dispose() method, to ensure '
'that all the resources used by the widget are fully released.' 'that all the resources used by the widget are fully released.'
...@@ -1503,7 +1504,7 @@ class ParentDataElement<T extends RenderObjectWidget> extends _ProxyElement { ...@@ -1503,7 +1504,7 @@ class ParentDataElement<T extends RenderObjectWidget> extends _ProxyElement {
} }
if (ancestor != null && badAncestors.isEmpty) if (ancestor != null && badAncestors.isEmpty)
return true; return true;
throw new WidgetError( throw new FlutterError(
'Incorrect use of ParentDataWidget.\n' + 'Incorrect use of ParentDataWidget.\n' +
widget.debugDescribeInvalidAncestorChain( widget.debugDescribeInvalidAncestorChain(
description: "$this", description: "$this",
...@@ -1975,7 +1976,7 @@ class MultiChildRenderObjectElement extends RenderObjectElement { ...@@ -1975,7 +1976,7 @@ class MultiChildRenderObjectElement extends RenderObjectElement {
continue; // when these nodes are reordered, we just reassign the data continue; // when these nodes are reordered, we just reassign the data
if (!idSet.add(child.key)) { if (!idSet.add(child.key)) {
throw new WidgetError( throw new FlutterError(
'Duplicate keys found.\n' 'Duplicate keys found.\n'
'If multiple keyed nodes exist as children of another node, they must have unique keys.\n' 'If multiple keyed nodes exist as children of another node, they must have unique keys.\n'
'$widget has multiple children with key "${child.key}".' '$widget has multiple children with key "${child.key}".'
...@@ -2021,14 +2022,6 @@ class MultiChildRenderObjectElement extends RenderObjectElement { ...@@ -2021,14 +2022,6 @@ class MultiChildRenderObjectElement extends RenderObjectElement {
} }
} }
class WidgetError extends AssertionError {
WidgetError(this.message);
final String message;
@override
String toString() => message;
}
typedef void WidgetsExceptionHandler(String context, dynamic exception, StackTrace stack); typedef void WidgetsExceptionHandler(String context, dynamic exception, StackTrace stack);
/// This callback is invoked whenever an exception is caught by the widget /// This callback is invoked whenever an exception is caught by the widget
/// system. The 'context' argument is a description of what was happening when /// system. The 'context' argument is a description of what was happening when
......
...@@ -79,14 +79,14 @@ class GestureDetector extends StatelessWidget { ...@@ -79,14 +79,14 @@ class GestureDetector extends StatelessWidget {
bool haveScale = onScaleStart != null || onScaleUpdate != null || onScaleEnd != null; bool haveScale = onScaleStart != null || onScaleUpdate != null || onScaleEnd != null;
if (havePan || haveScale) { if (havePan || haveScale) {
if (havePan && haveScale) { if (havePan && haveScale) {
throw new WidgetError( throw new FlutterError(
'Incorrect GestureDetector arguments.\n' 'Incorrect GestureDetector arguments.\n'
'Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan. Just use the scale gesture recognizer.' 'Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan. Just use the scale gesture recognizer.'
); );
} }
String recognizer = havePan ? 'pan' : 'scale'; String recognizer = havePan ? 'pan' : 'scale';
if (haveVerticalDrag && haveHorizontalDrag) { if (haveVerticalDrag && haveHorizontalDrag) {
throw new WidgetError( throw new FlutterError(
'Incorrect GestureDetector arguments.\n' 'Incorrect GestureDetector arguments.\n'
'Simultaneously having a vertical drag gesture recognizer, a horizontal drag gesture recognizer, and a $recognizer gesture recognizer ' '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.' 'will result in the $recognizer gesture recognizer being ignored, since the other two will catch all drags.'
...@@ -336,7 +336,7 @@ class RawGestureDetectorState extends State<RawGestureDetector> { ...@@ -336,7 +336,7 @@ class RawGestureDetectorState extends State<RawGestureDetector> {
void replaceGestureRecognizers(Map<Type, GestureRecognizerFactory> gestures) { void replaceGestureRecognizers(Map<Type, GestureRecognizerFactory> gestures) {
assert(() { assert(() {
if (!RenderObject.debugDoingLayout) { if (!RenderObject.debugDoingLayout) {
throw new WidgetError( throw new FlutterError(
'Unexpected call to replaceGestureRecognizers() method of RawGestureDetectorState.\n' 'Unexpected call to replaceGestureRecognizers() method of RawGestureDetectorState.\n'
'The replaceGestureRecognizers() method can only be called during the layout phase. ' 'The replaceGestureRecognizers() method can only be called during the layout phase. '
'To set the gesture recognisers at other times, trigger a new build using setState() ' 'To set the gesture recognisers at other times, trigger a new build using setState() '
......
...@@ -115,7 +115,7 @@ class Hero extends StatefulWidget { ...@@ -115,7 +115,7 @@ class Hero extends StatefulWidget {
final Map<Key, HeroState> tagHeroes = heroes.putIfAbsent(tag, () => <Key, HeroState>{}); final Map<Key, HeroState> tagHeroes = heroes.putIfAbsent(tag, () => <Key, HeroState>{});
assert(() { assert(() {
if (tagHeroes.containsKey(key)) { if (tagHeroes.containsKey(key)) {
new WidgetError( new FlutterError(
'There are multiple heroes that share the same key within the same subtree.\n' 'There are multiple heroes that share the same key within the same subtree.\n'
'Within each subtree for which heroes are to be animated (typically a PageRoute subtree), ' 'Within each subtree for which heroes are to be animated (typically a PageRoute subtree), '
'either each Hero must have a unique tag, or, all the heroes with a particular tag must ' 'either each Hero must have a unique tag, or, all the heroes with a particular tag must '
......
...@@ -181,7 +181,7 @@ class MimicableState extends State<Mimicable> { ...@@ -181,7 +181,7 @@ class MimicableState extends State<Mimicable> {
MimicableHandle startMimic() { MimicableHandle startMimic() {
assert(() { assert(() {
if (_placeholderSize != null) { if (_placeholderSize != null) {
throw new WidgetError( throw new FlutterError(
'Mimicable started while already active.\n' 'Mimicable started while already active.\n'
'When startMimic() or liftToOverlay() is called on a MimicableState, the mimic becomes active. ' 'When startMimic() or liftToOverlay() is called on a MimicableState, the mimic becomes active. '
'While active, it cannot be reactivated until it is stopped. ' 'While active, it cannot be reactivated until it is stopped. '
......
...@@ -262,7 +262,7 @@ class Navigator extends StatefulWidget { ...@@ -262,7 +262,7 @@ class Navigator extends StatefulWidget {
NavigatorState navigator = context.ancestorStateOfType(const TypeMatcher<NavigatorState>()); NavigatorState navigator = context.ancestorStateOfType(const TypeMatcher<NavigatorState>());
assert(() { assert(() {
if (navigator == null) { if (navigator == null) {
throw new WidgetError( throw new FlutterError(
'openTransaction called with a context that does not include a Navigator.\n' 'openTransaction called with a context that does not include a Navigator.\n'
'The context passed to the Navigator.openTransaction() method must be that of a widget that is a descendant of a Navigator widget.' 'The context passed to the Navigator.openTransaction() method must be that of a widget that is a descendant of a Navigator widget.'
); );
......
...@@ -90,7 +90,7 @@ class Overlay extends StatefulWidget { ...@@ -90,7 +90,7 @@ class Overlay extends StatefulWidget {
String additional = context.widget != debugRequiredFor String additional = context.widget != debugRequiredFor
? '\nThe context from which that widget was searching for an overlay was:\n $context' ? '\nThe context from which that widget was searching for an overlay was:\n $context'
: ''; : '';
throw new WidgetError( throw new FlutterError(
'No Overlay widget found.\n' 'No Overlay widget found.\n'
'${debugRequiredFor.runtimeType} widgets require an Overlay widget ancestor for correct operation.\n' '${debugRequiredFor.runtimeType} widgets require an Overlay widget ancestor for correct operation.\n'
'The most common way to add an Overlay to an application is to include a MaterialApp or Navigator widget in the runApp() call.\n' 'The most common way to add an Overlay to an application is to include a MaterialApp or Navigator widget in the runApp() call.\n'
......
...@@ -113,7 +113,7 @@ void main() { ...@@ -113,7 +113,7 @@ void main() {
); );
tester.pumpWidget(widget); tester.pumpWidget(widget);
tester.tap(tester.findElementByKey(targetKey)); tester.tap(tester.findElementByKey(targetKey));
expect(exception, new isInstanceOf<WidgetError>()); expect(exception, new isInstanceOf<FlutterError>());
expect('$exception', startsWith('openTransaction called with a context')); expect('$exception', startsWith('openTransaction called with a context'));
}); });
}); });
......
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