out_of_context 2.0.0 out_of_context: ^2.0.0 copied to clipboard
Out of Context provides context-free navigation & scaffolds in Flutter.
Out of Context - Context-free navigation & scaffolds #
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.
dependencies:
out_of_context: ^1.1.1
Then, use any of the Mixin
s 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.