Giter VIP home page Giter VIP logo

flutter_router's Introduction

Flutter Router

pub package

Flutter routing library that adds flexible routing options like parameters and clear route definitions.

Usage

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

Usage

// Import package
import 'package:flutter_router/flutter_router.dart';
runApp(MaterialApp(
  onGenerateRoute: Router({
    '/accounts/{id}': (context, match) => Account(id: match.parameters['id'),
    '/': (context, match) => Index(),
  }).get,
));

flutter_router's People

Contributors

ayad-ben-saliem avatar kusarm avatar peterzagoranski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ayad-ben-saliem

flutter_router's Issues

get() can throw, which Navigator does not expect

Router#get can throw if a route is not found. Because Navigator expects a return value of null if no route is found, it'd be good to wrap the function in a trycatch and return null so that onUnknownRoute can handle the error correctly.

Alternatively, we could provide a special case for a * or noMatch handler so that onGenerateRoute never actually fails to return a value.

Here's my widget and a stack trace for reference:

      Navigator(
        onUnknownRoute: (settings) {
          return MaterialPageRoute(
              fullscreenDialog: true,
              builder: (context) {
                return Container(color: Colors.red);
                );
              },
              settings: settings);
        },
        initialRoute: "broken",
        onGenerateRoute: Router({
          "/": (context, match) => MainScreen(),
          "/splash": (context, match) => SplashScreen(),
        }).get,
      ),
flutter: Bad state: No element
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0      Iterable.first (dart:core/iterable.dart:518:7)
flutter: #1      Router.get (package:flutter_router/flutter_router.dart:13:123)
flutter: #2      NavigatorState._routeNamed (package:flutter/src/widgets/navigator.dart:1426:29)
flutter: #3      NavigatorState.initState (package:flutter/src/widgets/navigator.dart:1367:17)

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.