Flutter The lightest, easiest and most convenient route management!

Overview

Language: English | 中文简体

GitHub stars GitHub forks GitHub issues

nav_router

nav_router is the simplest / lightweight / convenient routing management solution for flutter. It supports various routing animations, and it is very convenient to jump / pass parameters. To jump to a new page, just routePush (NewPage ());

Log

  • 2020.07.04-Test Flutter 1.17.3

  • 2020.06.03-Cancel pop default empty string data

  • 2020.02.28 - Fix pop method of dev branch flutter error.

Getting started

Add dependency

dependencies:
  nav_router: any #Specific version customization (any means latest)

Related articles updated ...

Then use flutter packages upgrade to update flutter plugin packages

Sample project

There is a pretty sweet example project in the example folder. Check it out. Otherwise, keep reading to get up and running.

Setting up

  • 1.Import our plugin on the page of MaterialApp
import 'package:nav_router/nav_router.dart';
  • 2.Write navGK value in navigatorKey property of MaterialApp
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: '',
      navigatorKey: navGK,
    );
  }
  • 3.Then, we can start using it, here is an example of a jump page
Widget buildItem(RouteModel item) {
  return new FlatButton(
    onPressed: () => routePush(new NewPage()),
    child: new Text('Click to jump'),
  );
}
  • 4.If we want to use other routing animations to jump, we can add jump properties later, such as: gradient animation
routePush(new NewPage(), RouterType.fade);

Parameter passing

Way 1:

Normally push the new page, but add Then at the back, the v behind is the data brought back by the page after we jump, and then we print it out.

routePush(NewPage()).then((v) {
  print('I received::$v');
});

Then our new page will pop the return value. Add our parameters directly in the pop and then the brackets. It can be any type of parameter value. After that, what we wrote above will receive the parameters we returned this time with the past.

FlatButton(
  onPressed: () {
    pop('This is the parameter');
  },
  child: Text('Return with parameters'),
),

Way 2:

Method two can use our NavData, first add the NavData type parameter to the page we want to push to,

class NewPage extends StatlessWidget {
  final NavData navData;

  NewPage({this.navData});
}

Then the following judges whether the navData is empty, that is, whether the superior has received this method, and if so, returns it with parameters.

FlatButton(
  onPressed: () {
    if(navData == null) return;
    widget.navData('NavData mode parameter transmission');
    pop();
  },
  child: Text('Return with parameters'),
),

Then the place where we push can use navData to receive the value and print it out.

routePush(NewPage(navData: (v) {
    print('I received::$v');
  }),
);

Effect map 图片不能显示点我

1.gif 2.gif 3.gif
4.gif 5.gif 6.gif
7.gif 8.gif 9.gif
10.gif 11.gif 12.gif

Flutter WeChat group

Above can't show my point

FlutterJ:www.flutterj.com

Contributor

LICENSE

fluttercandies/nav_router is licensed under the
Apache License 2.0

A permissive license whose main conditions require preservation of copyright and license notices. 
Contributors provide an express grant of patent rights. 
Licensed works, modifications, and larger works may be distributed under different terms and without source code.
You might also like...

Flutter ui boilerplate is easiest way to create new flutter project with clean code and well organized file folder.

Flutter ui boilerplate is easiest way to create new flutter project with clean code and well organized file folder.

Flutter UI Boilerplate "Sharing for fun" Flutter ui boilerplate is easiest way to create new flutter project with clean code and well organized file f

Dec 1, 2022

Easiest way to add support for light and dark theme in your flutter app.

Easiest way to add support for light and dark theme in your flutter app.

Adaptive Theme Easiest way to add support for light and dark theme in your Flutter app. It allows to manually set light or dark theme and also lets yo

Dec 27, 2022

EasiestSqlFlutter - The Easiest and the Laziest approach to Flutter SQL Database.

EasiestSqlFlutter - The Easiest and the Laziest approach to Flutter SQL Database.

The Easiest and the Laziest approach to Flutter SQL Database for Flutter. • How to use • Contribution • License • Support • Share Sharing with your fr

Jul 27, 2022

This library provides the optimized and easiest way to authenticate with Mastodon's OAuth 2.0 in your Flutter app 🎯

This library provides the optimized and easiest way to authenticate with Mastodon's OAuth 2.0  in your Flutter app 🎯

The Optimized and Easiest Way to Integrate OAuth 2.0 with Mastodon API in Flutter 🎯 1. Guide 🌎 1.1. Getting Started ⚡ 1.1.1. Install Library 1.1.2.

Jul 7, 2023

This library provides the easiest and powerful Dart/Flutter library for Mastodon API 🎯

This library provides the easiest and powerful Dart/Flutter library for Mastodon API 🎯

The Easiest and Powerful Dart/Flutter Library for Mastodon API 🎯 1. Guide 🌎 1.1. Features 💎 1.2. Getting Started ⚡ 1.2.1. Install Library 1.2.2. Im

Jul 27, 2023

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

The easiest way to style custom text snippets in flutter

The easiest way to style custom text snippets in flutter

Super Rich Text Check it out at Pub.Dev The easiest way to style custom text snippets Help Maintenance I've been maintaining quite many repos these da

Nov 4, 2022

This library provides the easiest way to integrate Twitter Cards in Flutter web apps 🐦

This library provides the easiest way to integrate Twitter Cards in Flutter web apps 🐦

The Easiest Way to Integrate Twitter Cards into Your Flutter Web App 🐦 1. Guide 🌎 1.1. Features 💎 1.2. Getting Started ⚡ 1.2.1. Install Library 1.2

Aug 7, 2022

The easiest way to create your animated splash screen in a fully customizable way.

The easiest way to create your animated splash screen in a fully customizable way.

Animated Splash Screen Check it out at Pub.Dev Do it your way Assets image Custom Widget Url image IconData Or just change PageTransition and/or Splas

Nov 10, 2022
Comments
  • 集成在flutter之后在vscode编译过程中报错

    集成在flutter之后在vscode编译过程中报错

    Compiler message: ../../Flutter_SDK/flutter/.pub-cache/hosted/pub.flutter-io.cn/nav_router-0.0.3/lib/src/commom.dart:271:29: Error: This expression has type 'void' and can't be used. return navGK.currentState.pop(result ?? '');

    opened by SuperZiLu 1
Owner
FlutterCandies
Custom Flutter candies (packages) for you to build your Flutter app easily. Enjoy it!
FlutterCandies
Flutter modal bottom route - A flutter route animation

flutter_modal_bottom_route This is a flutter route animation demo. See Chinouo J

null 4 Aug 19, 2022
Building a simple Flutter app for understanding the BLoC State Management including: Cubit, Managing Route & showSnackBar.

Building a simple Flutter app for understanding the BLoC State Management including: Cubit, Managing Route & showSnackBar.

TAD 8 Dec 3, 2022
Building a simple Flutter app * Switch Theme * for understanding the BLoC State Management including: Cubit Communications with StreamSubscription & Managing Route.

Building a simple Flutter app * Switch Theme * for understanding the BLoC State Management including: Cubit Communications with StreamSubscription & Managing Route.

TAD 1 Oct 3, 2022
Biyi - a convenient translation and dictionary app written in Flutter

biyi_app Biyi is a convenient translation and dictionary app written in Flutter.

biyidev 892 Dec 28, 2022
A convenient code generator for app styleguide, gallery, wireframes and/or storyboard.

Framy A convenient code generator for app styleguide, gallery, wireframes and/or storyboard. ?? Official documentation ?? Packages In order to use Fra

Fidev 145 Dec 19, 2022
Ruqe brings the convenient types and methods found in Rust into Dart, such as the Result, Option, pattern-matching, etc.

ruqe Ruqe brings the convenient types and methods found in Rust into Dart, such as the Result, Option, pattern-matching, etc. Additionally, the librar

Alexander Nitiola 12 Dec 28, 2022
A rich, convenient, easy-to-use flutter page transition package

flutter_page_transition A rich, convenient, easy-to-use flutter page transition package. README in Chinese Some Demos Getting Started Add this to your

Double Han 56 Sep 27, 2022
GetX - one of the most popular state management solution in flutter

GteX Tutorial - Udemy GetX is one of the most popular state management solution in flutter. In addition to state management, GetX provides easy way to

Md. Siam 3 May 18, 2022
A most easily usable cookie management library in Dart. With SweetCookieJar, you can easily manage cookie on your application.

A most easily usable cookie management library in Dart! 1. About 1.1. Introduction 1.1.1. Install Library 1.1.2. Import It 1.1.3. Use SweetCookieJar 1

Kato Shinya 9 Oct 27, 2022
A most easily usable cache management library in Dart. With CacheStorage, you can easily manage cache on your application.

A most easily usable cache management library in Dart! 1. About 1.1. Introduction 1.1.1. Install Library 1.1.2. Import It 1.1.3. Use CacheStorage 1.2.

Kato Shinya 1 Dec 13, 2021