Skip to content

Instantly share code, notes, and snippets.

@brandondiamond
Last active April 22, 2020 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandondiamond/0989d15eaed6f40971a71b8dc6617f8d to your computer and use it in GitHub Desktop.
Save brandondiamond/0989d15eaed6f40971a71b8dc6617f8d to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
class RootOverlayInjector extends Overlay {
final Widget child;
const RootOverlayInjector({Key key, this.child})
: super(key: key, initialEntries: const []);
@override
_RootOverlayInjectorState createState() => _RootOverlayInjectorState();
}
class _RootOverlayInjectorState extends OverlayState {
@override
BuildContext get context =>
super.context.findRootAncestorStateOfType<OverlayState>().context;
@override
Widget build(BuildContext context) => (widget as RootOverlayInjector).child;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment