Commit aef60030 authored by Hixie's avatar Hixie

Provide a way to insert multiple overlays at once.

parent 630284bd
......@@ -66,6 +66,18 @@ class OverlayState extends State<Overlay> {
});
}
void insertAll(Iterable<OverlayEntry> entries, { OverlayEntry above }) {
assert(above == null || (above._state == this && _entries.contains(above)));
for (OverlayEntry entry in entries) {
assert(entry._state == null);
entry._state = this;
}
setState(() {
int index = above == null ? _entries.length : _entries.indexOf(above) + 1;
_entries.insertAll(index, entries);
});
}
void _remove(OverlayEntry entry) {
setState(() {
_entries.remove(entry);
......
......@@ -41,11 +41,9 @@ abstract class OverlayRoute<T> extends Route<T> {
final List<OverlayEntry> _overlayEntries = <OverlayEntry>[];
void didPush(OverlayState overlay, OverlayEntry insertionPoint) {
for (WidgetBuilder builder in builders) {
for (WidgetBuilder builder in builders)
_overlayEntries.add(new OverlayEntry(builder: builder));
overlay?.insert(_overlayEntries.last, above: insertionPoint);
insertionPoint = _overlayEntries.last;
}
overlay?.insertAll(_overlayEntries, above: insertionPoint);
}
// Subclasses shouldn't call this if they want to delay the finished() call.
......
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