fast_route 0.0.2
fast_route: ^0.0.2

Flutter Android iOS web

fast_route is a custom Flutter routing library inspired by vue-router.

fast_route #

fast_route is a custom Flutter routing library inspired by vue-router.

Version

Getting started #

You should ensure that you add the router as a dependency in your flutter project.

dependencies:
 fast_route: "^0.0.2"

Example #

import 'package:fast_route/fast_route.dart';
import 'package:shared_preferences/shared_preferences.dart';

List<FastRoute> routes = [
  FastRoute(
    path: '/',
    builder: (context, params) => Home(),
    beforeEnter: (from,to) async { // Custom guard

        SharedPreferences prefs = await SharedPreferences.getInstance();

        bool isLoggedIn = prefs.getBool('loggedIn');

        if (isLoggedIn == false) {
            return FastRouter.routeByName('login');
        }

        return to;   
    },
  ),
  FastRoute(
    path: '/login',
    name: "login",
    builder: (context, params) => Login(),
  ),
];

import 'package:fast_route/fast_route.dart';
import 'package:shared_preferences/shared_preferences.dart';

List<FastRoute> routes = [
  FastRoute(
    path: '/',
    builder: (context, params) => Home(),
    beforeEnter: (from,to) async { // Custom guard

        SharedPreferences prefs = await SharedPreferences.getInstance();

        bool isLoggedIn = prefs.getBool('loggedIn');

        if (isLoggedIn == false) {
            return FastRouter.routeByName('login');
        }

        return to;   
    },
  ),
  FastRoute(
    path: '/login',
    name: "login",
    builder: (context, params) => Login(),
  ),
];

import 'package:fast_route/fast_route.dart';
import 'package:flutter/material.dart';

import 'routes.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Material App Bar'),
        ),
        body: FastRouter(
          routes: routes,
        ),
      ),
    );
  }
}
1
likes
100
pub points
8%
popularity

Publisher

kabbouchi.com

fast_route is a custom Flutter routing library inspired by vue-router.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on fast_route