Commit 8b1dd598 authored by Hans Muller's avatar Hans Muller

Merge pull request #376 from HansMuller/stocks_bug

Safely clear SnackBack and BottomSheet placeholders

Correct one stocks demo bug: displaying the stock symbol viewer (single tap on a row) while a BottomSheet or SnackBar was up, would assert.

Thep SnackBack and BottomSheet placeholder keys are cleared when they're obscured by a route with an opaque OverlayEntry. So in that case there's no need to try and clear the placeholder's child again.
parents 1ddc71aa 7955995f
......@@ -221,6 +221,9 @@ Future showBottomSheet({ BuildContext context, GlobalKey<PlaceholderState> place
placeholderKey.currentState.child = new _PersistentBottomSheet(route: route);
Navigator.of(context).pushEphemeral(route);
return completer.future.then((_) {
// If our overlay has been obscured by an opaque OverlayEntry then currentState
// will have been cleared already.
if (placeholderKey.currentState != null)
placeholderKey.currentState.child = null;
});
}
......@@ -108,9 +108,16 @@ Future showSnackBar({ BuildContext context, GlobalKey<PlaceholderState> placehol
content: content,
actions: actions
);
// TODO(hansmuller): https://github.com/flutter/flutter/issues/374
assert(placeholderKey.currentState.child == null);
placeholderKey.currentState.child = snackBar;
Navigator.of(context).pushEphemeral(route);
return completer.future.then((_) {
// If our overlay has been obscured by an opaque OverlayEntry currentState
// will have been cleared already.
if (placeholderKey.currentState != null)
placeholderKey.currentState.child = null;
});
}
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