From f86889cb1b4f26fda7669f73e79e1c6e242f0449 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Sun, 6 Mar 2016 11:10:39 -0800 Subject: [PATCH] Clarify the assert when mimicking twice in a row. --- packages/flutter/lib/src/widgets/mimic.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/widgets/mimic.dart b/packages/flutter/lib/src/widgets/mimic.dart index ec0d5769dd..38fb20468f 100644 --- a/packages/flutter/lib/src/widgets/mimic.dart +++ b/packages/flutter/lib/src/widgets/mimic.dart @@ -176,7 +176,18 @@ class MimicableState extends State { /// passing it to a [Mimic] widget. To mimic the child in the /// [Overlay], consider using [liftToOverlay()] instead. MimicableHandle startMimic() { - assert(_placeholderSize == null); + assert(() { + if (_placeholderSize != null) { + throw new WidgetError( + 'Mimicable started while already active.\n' + 'When startMimic() or liftToOverlay() is called on a MimicableState, the mimic becomes active. ' + 'While active, it cannot be reactivated until it is stopped. ' + 'To stop a Mimicable started with startMimic(), call the MimicableHandle object\'s stopMimic() method. ' + 'To stop a Mimicable started with liftToOverlay(), call dispose() on the MimicOverlayEntry.' + ); + } + return true; + }); RenderBox box = context.findRenderObject(); assert(box != null); assert(box.hasSize);