Skip to content
pubscout

one_context

4.1.0, released 2 years ago by an unverified publisher

Manage navigation, dialogs, overlays, and themes globally without a BuildContext.

WASM-ready
$ flutter pub add one_context
Source repository

What it does

OneContext allows Flutter developers to interact with navigators, overlays, dialogs, media queries, and themes from anywhere in the app without requiring a BuildContext. It wraps standard Flutter operations into a singleton interface.

AI-written summary of version 4.1.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to trigger navigation or dialogs from outside the widget tree (like in BLoCs, services, or view models)
  • You want a simple global solution for handling overlays and progress indicators

Skip it when

  • You prefer strictly context-based architectural patterns
  • You need complex state management systems where global context access causes unintended rebuild issues

Strengths

  • No BuildContext required for navigation and dialogs
  • Uses familiar native Flutter function names and parameters
  • Fast O(1) performance

Weaknesses

  • Global context usage can sometimes lead to unexpected behavior if not handled carefully
  • May bypass standard InheritedWidget lookup mechanisms if using root context directly

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
2

Configure MaterialApp with OneContext().builder in the builder property and OneContext().key in the navigatorKey property.

return MaterialApp(
    builder: OneContext().builder,
    navigatorKey: OneContext().key,
);

// Later anywhere:
OneContext().pushNamed('/detail_page');

Alternatives

Packages that do the same job and could replace one_context.

  • short_navigation

    Navigate between routes, show dialogs, and access context globally without passing BuildContext.

  • navigation_utils

    A Navigator 2 wrapper bringing back Navigator 1 style APIs with deep linking and URL routing.

Works with

Packages commonly used together with one_context: ones it builds on, ones built on it, and its own family.