Commit 7955995f authored by Hans Muller's avatar Hans Muller

Safely clear SnackBack and BottomSheet placeholders

parent b6234414
......@@ -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((_) {
placeholderKey.currentState.child = null;
// 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((_) {
placeholderKey.currentState.child = null;
// 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