context_holder 0.0.4
context_holder: ^0.0.4 copied to clipboard

Flutter Android iOS web

A flutter build context holder, very easy to use, init once, use everywhere. Enjoy!

Build Context Holder for Flutter Pub version #

A flutter build context holder, init once, use everywhere.

1. Add dependency #

dependencies:
  context_holder: ^0.0.4

2. Import context holder #

import 'package:context_holder/context_holder.dart';

3. Init context holder #

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(),
    ),
  );
}

4. Now you can use it everywhere! #

Get the current build context.

ContextHolder.currentContext

Get the current state.

ContextHolder.currentState

Get the current widget.

ContextHolder.currentWidget

Get the current overlay.

ContextHolder.currentOverlay
1
likes
110
pub points
0%
popularity

A flutter build context holder, very easy to use, init once, use everywhere. Enjoy!

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

pmgd19881226@gmail.com

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on context_holder