Last updated:
0 purchases
flutter util generator
What is flutter_util_generator #
Flutter_util_generator is a file generator for flutter that will allow you tu easily generate files.
Install the package by running this command in your terminal :
flutter pub add flutter_util_generator
copied to clipboard
or by adding this to your pubspec.yaml file :
dev_dependencies:
flutter_util_generator: last_version
copied to clipboard
How to use #
Chose between the different generators and run the command in your terminal.
Bloc generator #
One feature is to generate a bloc file with the bloc pattern in the following structure :
example_bloc
├── bloc
│ ├── bloc.dart
│ ├── bloc_event.dart
│ └── bloc_state.dart
└── view
└── view.dart
copied to clipboard
To generate the files, run this command in your terminal :
flutter pub run flutter_util_generator:generate_bloc --name blocName --path path/to/your/bloc
copied to clipboard
or
flutter pub run flutter_util_generator:generate_bloc -n blocName -p path/to/your/bloc
copied to clipboard
Router generator #
Generate all the files needed to use and set up the package go_router that uses a ShellRoute to surround most of the routes of your app.
The generated code uses the package go_router to generate the routes.
You can choose between two types of ShellRoutes :
Navigation Bar
Navigation Rail
navigation
├── app_router.dart
├── routes.dart
├── scaffold_with_nav_bar.dart
└── scaffold_with_nav_bar_destination.dart
copied to clipboard
navigation
├── app_router.dart
├── routes.dart
├── scaffold_with_navigation_rail.dart
└── scaffold_with_navigation_rail_destination.dart
copied to clipboard
To generate the files, run this command in your terminal :
flutter pub run flutter_util_generator:generate_router --type rail --path path/to/your/navigation
flutter pub run flutter_util_generator:generate_router --type navbar --path path/to/your/navigation
copied to clipboard
Once the files are generated, you can change the routes and the tabs of the rail or nav bar to your needs.
You also need to set custom routes in the app_router.dart file and in the routes.dart file.
To use the new router in your app, you need to make changes in your MyApp widget:
Replace
return MaterialApp(
[...]
)
copied to clipboard
with
return MaterialApp.router(
routerConfig: AppRouter.getInstance().router,
[...]
)
copied to clipboard
You'll also need to remove the onGenerateRoute: part.
and you're good to go !
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.