Code Monkey home page Code Monkey logo

flutter_nested_navigation's Introduction

Flutter Nested Stateful Navigation

Nested navigation package that allows having an individual stateful navigator for each tab of BottomNavigationBar.

The plugin enables Instagram-like User Experience i.e. new screens pushed in the tab navigators do not overlay the entire app view, allowing the user to browse inner routes of multiple tabs. Every tab uses its own Navigator with the help of ShellRoute.

The package is based on StatefulShellRoute proposition by tolo.

Getting started

To use this plugin, add flutter_nested_navigation as a dependency in your pubspec.yaml file.

Usage

First, import flutter_nested_navigation and declare your tab widgets with the NestedNavigationTabRoutes mixin:

class ExampleTab extends StatelessWidget with NestedNavigationTabRoutes {

  @override
  final routes = [
    GoRoute(
      path: 'details',
      builder: (context, state) => SomeChildScreen(),
    ),
  ];

  ...
}

Next, create your router by calling createNestedRouter:

final router = createNestedRouter(tabs: [
  NestedNavigationTabItem(
    defaultLocation: '/a',
    name: 'Page A',
    icon: Icons.home,
    body: ExampleTab(name: 'Page A',
  ),
  NestedNavigationTabItem(
    defaultLocation: '/b',
    name: 'Page B',
    icon: Icons.home,
    body: ExampleTab(name: 'Page B'),
  ),
]);

And finally, use the created router e.g. by calling MaterialApp.router(routerConfig: router).

See example/example.dart for more details.

flutter_nested_navigation's People

Contributors

g-30 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

flutter_nested_navigation's Issues

Nested Navigation Fails After Multiple Nested Routes Opened

I am following the Nested stateful navigation with ShellRoute #2650 on Flutter and saw your comment. Thanks for sharing. There is a bug in the code. The following steps will replicate the bug:

  1. When your example app loads, it shows 'Page A'. Click on 'Go to details'. Leave that page open.
  2. Click on 'Page B' in the bottom navbar. 'Page B' will display. Click on 'Go to details'. Leave that page open.
  3. In the bottom navbar, click 'Page A'.
  4. At the top appbar, click on the back arrow ⬅. You should still be on 'Page A'.
  5. Click on 'Go to details' under 'Page A' in the center again. It won't go anywhere.
  6. Click on 'Page B' in the bottom navbar. 'Details /b/details' will display.
  7. At the top appbar, click on the back arrow ⬅. The screen will change to 'Page B'.
  8. Click on 'Go to details' under 'Page B' in the center again. It won't go anywhere.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.