Line data Source code
1 : import 'package:flutter/material.dart' show Widget, BuildContext; 2 : 3 : import '../../presentation/pages/home/home_page.dart'; 4 : import '../../presentation/pages/favorites/favorites_page.dart'; 5 : import '../../presentation/pages/details/movie_details_page.dart'; 6 : 7 : import '../../domain/entities/models/mdl_the_movie.dart'; 8 : 9 : /// Centralizes route names for application navigation. 10 : /// 11 : /// The [Routes] class defines static constants for each route used in the app, ensuring consistency and type safety when navigating between pages. 12 : /// 13 : /// ### Usage 14 : /// Use these constants as route names in navigation methods, route maps, and anywhere you need to reference a route string. 15 : /// 16 : /// ### Routes 17 : /// - [home]: Route name for the home page (`/home`). 18 : /// - [details]: Route name for the details page (`/details`). 19 : /// - [favorites]: Route name for the favorites page (`/favorites`). 20 : /// 21 : /// ### Example 22 : /// ```dart 23 : /// Navigator.pushNamed(context, Routes.details); 24 : /// ``` 25 : class Routes { 26 : /// Route name for the home page (`/home`). 27 : static const home = '/home'; 28 : 29 : /// Route name for the details page (`/details`). 30 : static const details = '/details'; 31 : 32 : /// Route name for the favorites page (`/favorites`). 33 : static const favorites = '/favorites'; 34 : 35 : /// Private constructor to prevent instantiation. 36 : Routes._(); // coverage:ignore-line 37 : } 38 : 39 : /// Provides a map of application routes to their corresponding widget builders. 40 : /// 41 : /// This method returns a map where each entry represents a route and its associated widget builder function. 42 : /// 43 : /// **Returns:** 44 : /// - A [Map<String, Widget Function(BuildContext)>] where the keys are route names and the values are functions that build widgets. 45 : /// 46 : /// **Route Entries:** 47 : /// - `'Routes.home'` (String): Route name for the home page, associated with [HomePage]. 48 : /// - `'Routes.details'` (String): Route name for the details page, associated with [MovieDetailsPage]. 49 : /// - `'Routes.favorites'` (String): Route name for the favorites page, associated with [FavoritesPage]. 50 1 : Map<String, Widget Function(BuildContext)> get appRoutes { 51 1 : return { 52 1 : Routes.home: (_) => const HomePage(), 53 3 : Routes.details: (_) => MovieDetailsPage(movie: TheMovie.empty()), 54 1 : Routes.favorites: (_) => const FavoritesPage(), 55 : }; 56 : }