Line data Source code
1 : import 'package:flutter/material.dart'; 2 : 3 26 : enum OverlayKeys { 4 26 : EDITOR_OVERLAY_KEY, 5 26 : PAGE_OVERLAY_KEY, 6 : } 7 : 8 : /// This helps manage [OverlayEntry] into the stack 9 : /// You can call Overlayed.removeOverlay(context, key) just 10 : /// as you do with navigator 11 : class Overlayed extends InheritedWidget { 12 : 13 : final Map<OverlayKeys, OverlayEntry> entries = new Map(); 14 : 15 6 : Overlayed({ 16 : Key key, 17 : @required Widget child, 18 0 : }) : assert(child != null), 19 6 : super(key: key, child: child); 20 : 21 8 : static Overlayed of(BuildContext context) => context.dependOnInheritedWidgetOfExactType<Overlayed>(); 22 : 23 3 : static void removeOverlay(BuildContext context, OverlayKeys key) { 24 3 : var instance = context.dependOnInheritedWidgetOfExactType<Overlayed>(); 25 9 : instance?.entries[key]?.remove(); 26 6 : instance?.entries?.remove(key); 27 : } 28 : 29 0 : @override 30 : bool updateShouldNotify(Overlayed old) => false; 31 : 32 : }