A flutter build context holder, init once, use everywhere.
dependencies:
context_holder: ^0.0.5import 'package:context_holder/context_holder.dart';Set your root app's navigatorKey with ContextHolder.key
For MaterialApp
void main() {
runApp(
MaterialApp(
/// must set the navigatorKey!!!!!!
navigatorKey: ContextHolder.key,
home: Scaffold(),
),
);
}For CupertinoApp
void main() {
runApp(
CupertinoApp(
/// must set the navigatorKey!!!!!!
navigatorKey: ContextHolder.key,
home: Scaffold(),
),
);
}Get the current build context.
ContextHolder.currentContextGet the current state.
ContextHolder.currentStateGet the current widget.
ContextHolder.currentWidgetGet the current overlay.
ContextHolder.currentOverlay