FlutterNavigator is a dart library for dealing with the Navigator API without a build context

Overview

FlutterNavigator

FlutterNavigator is a dart library for dealing with the Navigator API without a build context. This package wraps the NavigatorKey and provides a cleaner service for navigating without context in your flutter application.

Installation

Use the pubspec.yaml file to install the dependency.

flutter_navigator: ^0.1.2

Usage

Adding the Navigator Key

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Navigator Key',
      navigatorKey: FlutterNavigator().navigatorKey,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const PageOne(),
    );
  }
}

You need to provide the navigator key to your MaterialApp as that is how the service will communicate with the navigator state without the build context.

Using the FlutterNavigator

final FlutterNavigator _flutterNavigator = FlutterNavigator();

_flutterNavigator.push(PageTwo.route());

The FlutterNavigator is a singleton service so it will always keep the same instance throughout the lifetime of the application. You can call the Navigator API methods through the service (like 'push', 'pop', 'pushAndRemoveUntil', etc)... It's that simple!

Using the FlutterNavigator Observers

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Observers',
      navigatorKey: FlutterNavigator().navigatorKey,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      navigatorObservers: [
        FlutterNavigator().routeObserver,
      ],
      home: const PageOne(),
    );
  }
}

As with the navigator key, you can use the route observer provided by the service and this can be accessed throughout the application.

Creating your own implementation

class CustomFlutterNavigator implements IFlutterNavigator

To create your own implementation, all you need to do is implement the interface IFlutterNavigator and provide all the needed methods and properties.

Examples

  • BLoC Navigation - an example of how to use the FlutterNavigator within a BLoC.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

You might also like...

Build different UIs for Android, iOS, Web, Desktop, Wear, TV etc without the if/else checks in your widgets.

Build different UIs for Android, iOS, Web, Desktop, Wear, TV etc without the if/else checks in your widgets.

platform_widget_mixin Plugin to decouple widgets based on various platform properties. Features Build different UIs for Android, iOS, Web, Desktop, We

Nov 17, 2022

Bringing back contex.read and context.watch for riverpod

This package brings back the context extensions for riverpod that were discontinued in version 1.0.0. To read any provider, do context.read(myProvider

Sep 28, 2022

The easiest way to use navigation, context less and useful methods.

The easiest way to use navigation, context less and useful methods.

Starlight Utils The easiest way to use navigation, context less and useful methods. Features Name Status Context Less Navigation Service ✅ Context Les

Jul 10, 2022

Flutter project being built in the context of Smart India Hackathon { SIH }.

e_chardham_yatra A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Dec 29, 2022

Flutter In-Context Editing example

Flutter In-Context Editing example

Flutter In-Context Editing example Instantly see how your translations fit on a real device without unnecessary app builds Setup Clone the repo Run fl

Jun 3, 2022

Multi-language support in Flutter without using any third-party library

flutter_localization_app A new Flutter application. Getting Started This project is a starting point for a Flutter application. A few resources to get

Oct 30, 2021

🌰🌰 [BLOC_PATTERN] [RXDART] [STREAM] 🍄🍄 Simple auth app flutter, server node.js, BLoC pattern, RxDart 🍁🍁 Functionalities: LOGIN, REGISTER, CHANGE PASSWORD, CHANGE AVATAR, FORGOT PASSWORD. Pure rxdart BLoC pattern. BLoC pattern without library.

🌰🌰 [BLOC_PATTERN] [RXDART] [STREAM] 🍄🍄 Simple auth app flutter, server node.js, BLoC pattern, RxDart 🍁🍁 Functionalities: LOGIN, REGISTER, CHANGE PASSWORD, CHANGE AVATAR, FORGOT PASSWORD. Pure rxdart BLoC pattern. BLoC pattern without library.

node_auth #node-auth-flutter-BLoC-pattern-RxDart ❄️ ❄️ BLoC pattern rxdart stream 🐋 🐋 Simple auth app flutter, server node.js, BLoC pattern, RxDart

Dec 29, 2022

Ever want to create a quick form without wiring everything up? This might be the library for you.

Ever want to create a quick form without wiring everything up? This might be the library for you.

Sep 13, 2022

A flutter plugin to play Youtube Videos without API Key in range of Quality(144p, 240p,360p,480p,720p and 1080p).

Youtube Player Plugin This plugin is discontinued. Please use youtube_player_flutter which is an officially provided way of playing youtube videos, su

Nov 13, 2022
Owner
Luke Moody
Flutter | Dart | C# | .NET
Luke Moody
A routing package that lets you navigate through guarded page stacks and URLs using the Router and Navigator's Pages API, aka "Navigator 2.0".

A Flutter package to help you handle your application routing and synchronize it with browser URL. Beamer uses the power of Router and implements all

Sandro Lovnički 485 Jan 7, 2023
Flutter-context-menus - A flutter package to show context menus on right-click or long-press

context_menus A package to show context menus on right-click or long-press. ?? I

null 0 Jan 18, 2022
Riverpod University. App that shows my way of dealing with state management in Flutter.

Riverpod University A Flutter project that showcases Riverpod possibilities created with https://flutlab.io Realized thusfar: Counter, Light/Dark butt

:plotsklapps 5 Dec 18, 2022
Build context - Access most used properties in your BuildContext instance.

Languages: English | Brazilian Portuguse BuildContext Access most used properties in your BuildContext instance. This package relies on Dart's extensi

Pedro Massango 132 Dec 11, 2022
A customizable Flutter library that provides a circular context menu

Flutter Pie Menu ?? A customizable Flutter library that provides a circular context menu similar to Pinterest's. Usage Wrap the widget that will react

Raşit Ayaz 14 Jan 4, 2023
A wrapper around Navigator 2.0 and Router/Pages to make their use a easier.

APS Navigator - App Pagination System This library is just a wrapper around Navigator 2.0 and Router/Pages API that tries to make their use easier: ??

Guilherme Silva 14 Oct 17, 2022
flutter_thrio makes it easy and fast to add flutter to existing mobile applications, and provide a simple and consistent navigator APIs.

中文文档 英文文档 问题集 原仓库不再维护,代码已经很老了 最近版本更新会很快,主要是增加新特性,涉及到混合栈的稳定性的问题应该不多,可放心升级,发现问题加 QQ 群号码:1014085473,我会尽快解决。 不打算好好看看源码的使用者可以放弃这个库了,因为很多设定是比较死的,而我本人不打算花时间写

null 290 Dec 29, 2022
flutter_thrio makes it easy and fast to add flutter to existing mobile applications, and provide a simple and consistent navigator APIs.

本仓库不再维护,可移步新仓库 https://github.com/flutter-thrio/flutter_thrio 中文文档 问题集 QQ 群号码:1014085473 The Navigator for iOS, Android, Flutter. Version 0.2.2 requir

Hellobike 732 Dec 5, 2022
Aplicação para aula sobre Scaffold, Drawer e Navigator

scaffold_class A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started i

Deyvid J. Lira 7 Dec 27, 2022