Out of Context - Context-free navigation & scaffolds

Out of Context Build Codecov Pub Dev Documentation

Navigation in Flutter involves a great deal of ceremony as a BuilderContext must always be passed to a Navigator. A BuilContext must be passed down from a Widget to the calling method, which is needlessly verbose. It also makes testing hard as the navigation methods are static and cannot be mocked.

Out of Context provides (over-glorified) wrappers for context-free navigation and scaffolds.

Please view the stable brunch for a production version.

Using out_of_context

To import the library, add the following dependency to your project.

  out_of_context: ^1.1.1

Then, use any of the Mixins provided.

import 'package:out_of_context/out_of_context.dart';

class Fancy with DispatcherMixin {

  // router is provided by the DispatcherMixin
  // Look Ma, no BuildContexts!
  void back() => dispatcher.pop();


Mock of Context

Mock of Context is a companion project that provides mocks to simplify testing.

Please see the project here.


Context-free navigation & scaffolds in Flutter.