flutter_easy_routing 0.0.4 copy "flutter_easy_routing: ^0.0.4" to clipboard
flutter_easy_routing: ^0.0.4 copied to clipboard

Flutter Easy Routing - Navigation Make Easy - Use it Easy

Flutter Easy Routing #

A lightweight, flexible routing solution for Flutter applications that simplifies route management with type-safe navigation and customizable transitions.

pub package license

Flutter Easy Routing

Features #

  • 🧭 Type-safe navigation - No more string-based routes
  • πŸ”„ Custom transitions - Smooth animations between screens
  • πŸ›£οΈ Route generation - Simplified route setup
  • πŸ—ΊοΈ Route mapping - Easy management of route names
  • πŸ“± Platform adaptive - Uses CupertinoPageRoute on iOS
  • 🧩 Extension methods - Intuitive context-based navigation APIs

Installation #

Add flutter_easy_routing to your pubspec.yaml:

dependencies:
  flutter_easy_routing: 

Then run:

flutter pub get

Import the package:

import 'package:flutter_easy_routing/flutter_easy_routing.dart';

Basic Usage #

Setup #

  1. Define your route names by extending AppRoutes:
class Routes extends AppRoutes {
  const Routes._(super.name);

  static const home = Routes._('home');
  static const profile = Routes._('profile');
  static const settings = Routes._('settings');
}
  1. Configure the navigator in your MaterialApp:
MaterialApp(
    title: 'Flutter Easy Routing Demo',
    debugShowCheckedModeBanner: false,

    /// TODO : add following configuations
    navigatorKey: AppRouter.navigatorKey,
    onGenerateRoute: (settings) => AppRouter.generateRoute(settings, MyHomePage()),
    //

    theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
    ),
)

Create Routes #

Create routes by implementing the BaseRoute mixin:

class MyHomePage extends StatefulWidget with BaseRoute {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();

  /// TODO : override following properties (transitionType is option, if not given than takes default that set on material app)
  @override
  AppRoutes get routeName => Routes.home;

  @override
  Widget get screen => this;

  @override
  TransitionType get transitionType => TransitionType.fade;
}
/// next code

Navigate using context extensions:

// Navigate to a route
context.push(HomePage().route);

// Navigate to a named route
context.pushNamed(HomePage());

// Replace current route
context.pushReplacement(ProfilePage());

// Clear stack and navigate
context.pushAndRemoveUntil(HomePage(), (route) => route.settings.name == Routes.home.path);

// Go back
context.pop();

/// and all other methods like Navigator..

Global Context #

If you have no context than AppRouter provide navigation context:

final BuildContext context = AppRouter.context;
final NavigatorState navigatorState = AppRouter.state;

Transition Types #

You can choose from several transition types:

  • TransitionType.fade - Fade transition
  • TransitionType.slideUp - Slide up from bottom
  • TransitionType.slideLeft - Slide in from right
  • TransitionType.scale - Scale transition
  • TransitionType.size - Size transition

Set a global default transition:

void main() {
  RouteConfig.setDefaultTransition(TransitionType.slideLeft);
  runApp(MyApp());
}

Route with Arguments #

Pass arguments with your routes:


class NextPage extends StatelessWidget with BaseRoute {
  final int count;

  const NextPage({super.key, required this.count});

  @override
  AppRoutes get routeName => Routes.next;

  @override
  Widget get screen => this;

  /// --- other code --
}

// Navigate with arguments
context.pushNamed(NextPage(count: 10));

Custom Route #

Use the CustomRoute class for quick route creation without defining a separate class:

final detailsRoute = CustomRoute(
  routename: Routes.details,
  page: DetailsScreen(item: selectedItem),
  transition: TransitionType.scale,
);

context.pushNamed(detailsRoute);

🌟 Love this package? Give it a ⭐ on GitHub & show some πŸ’– β€” your support means everything!
~ πŸ‘€ Nayan Parmar

Contributing #

Contributions are welcome! Please feel free to submit a Pull Request.

License #

This package is licensed under the MIT License - see the LICENSE file for details.

11
likes
150
points
370
downloads

Publisher

verified publishertcircle.kesug.com

Weekly Downloads

Flutter Easy Routing - Navigation Make Easy - Use it Easy

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_easy_routing