Git Product home page Git Product logo

navigator_20_example's Introduction

Navigator 2.0 examples

Web demo of Router usage.

Navigator 2.0 Pages API example and Router example.

The main point of these examples is to show how to extract basic navigation logic to separate class (e.g. ChangeNotifier). I'm using 2 approaches:

  • Pages API
  • Router widget

Both of them use separate PageManager (or RoutePageManager) to handle navigation stack.

Pages API

Navigator's Pages API is a convenient way to declaratively set navigation stack in your Flutter app. Take a look at the main.dart entry point and please notice custom PageManager class that is handling list of pages provided to Navigator.

Router widget

For more complex and robust needs you may use the Router widget. Simple implementation can be found in main_router.dart entry point. Take a look at the custom TheAppPath class storing typed path information and RoutePageManager handling list of pages provided to the Navigator.

Web address handling

Because the RoutePageManager is notifying the Router about its changes and the currentPath is used as currentConfiguration the address bar in the browser is reflecting the stack changes:

  @override
  TheAppPath get currentConfiguration => pageManager.currentPath;

More

Run on Flutter dev (1.23)

Presentation at Flutter Cracow (Sept. 17th, 2020)

Presentation at DevFest Poland 2020

Presentation at Geekle Cross-Platform Mobile Development Summit 2020

Special thanks to Simon Lightfoot and Andrew Coutts.

See more also in the Stocks app example using Router.

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.