MIVE ROUTE

A powerful command-line tool for generating Go Router configuration files in Dart/Flutter projects. Automate the creation and management of typed routes with automatic code generation.

Features

  • 🚀 Fast Route Generation: Generate route files with a single command
  • 📝 Automatic Code Generation: Automatically creates and updates route configuration files
  • 🎯 Type-Safe Routes: Generate type-safe route definitions for Go Router
  • 📦 Clean Architecture: Built using Clean Architecture principles (Domain, Use Case, Repository, Data layers)
  • 🔧 Parameter Extraction: Automatically detects and extracts route parameters (e.g., :id)
  • 📄 Multiple File Generation: Creates route files, route names, route paths, and app router configuration

Overview

MIVE Dart Road simplifies the process of setting up and managing routes in Flutter applications using Go Router. Instead of manually creating route files and maintaining route definitions across multiple files, this tool generates consistent, well-organized route code automatically.

Installation

This is a standalone Dart command-line tool. Install it globally using:

dart pub global activate mive_route

Then you can use the mive_routes command from anywhere in your terminal.

Quick Start

Basic Usage

Generate a new route with a simple command:

mive_routes --name home --path /home

This creates:

  • A route file in lib/core/navigation/routes/home_route.dart
  • Updates lib/core/navigation/route_names.dart with the route name
  • Updates lib/core/navigation/route_paths.dart with the route path
  • Updates lib/core/navigation/app_router.dart with the router configuration

With Parameters

Generate routes with path parameters:

mive_routes --name profile --path /profile/:id
mive_routes --name post --path /post/:id/comments/:commentId

The tool automatically detects parameters and generates appropriate code for accessing them.

Usage Examples

Example 1: Simple Route

mive_routes --name dashboard --path /dashboard

Generated Files:

  • lib/core/navigation/routes/dashboard_route.dart - Route definition
  • Updated route_names.dart - Adds static const String dashboard = 'dashboard';
  • Updated route_paths.dart - Adds static const String dashboard = '/dashboard';
  • Updated app_router.dart - Adds route to GoRouter configuration

Example 2: Route with Parameters

mive_routes --name user --path /user/:userId

Generates route configuration for accessing user-specific pages with automatic parameter handling.

Example 3: Nested Routes with Multiple Parameters

mive_routes --name comment --path /post/:postId/comment/:commentId

Command Options

  • --name or -n (required): Route name (e.g., home, profile, user_details)
  • --path or -p (required): Route path (e.g., /home, /profile/:id, /post/:postId/comment/:commentId)
  • --help or -h: Display help information

Architecture

This tool is built using Clean Architecture principles:

  • Domain Layer: Contains RouteEntity and RouteRepository interface
  • Use Case Layer: GenerateRouteUseCase handles business logic
  • Data Layer: FileSystemRouteRepository manages file operations
  • Utilities: Template generation and file writing utilities

Generated File Structure

After running the tool, your project will have:

lib/
└── core/
    └── navigation/
        ├── routes/
        │   ├── home_route.dart
        │   ├── profile_route.dart
        │   └── ...
        ├── route_names.dart      (All route name constants)
        ├── route_paths.dart      (All route path constants)
        └── app_router.dart       (GoRouter configuration)

Requirements

  • Dart SDK: ^3.10.1
  • Go Router: ^17.0.0
  • Args: ^2.7.0

License

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

Contributing

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

Support

For issues, questions, or suggestions, please open an issue on the GitHub repository.