A Flutter Bootstrap Project
This project is a starting point for a Flutter application. It has built in dependencies pre configured to handle multiple things
- Git clone this project
- Run
dart init.dart
and follow instructions to configure package name - Run
flutter pub get
- You're good to go
Here is the list of all dependencies that are preconfigures for the project and the architecture of its folders
- State Management by Riverpod
- Data classes by Freezed
- Routing by GoRouter
- Translations by Slang
- Network by Dio
- Logging by Logger
In a majority of those dependencies, code generation is used, so your best friend will be dart run build_runner watch -d
which will run in background during all the dev phase of the project
At some points, slang should use it to, but it is not working sometimes, so you might need to use dart run slang
There are two main folders that are pre-structures, assets and lib
assets stores some translations, as we are using Slang, our translations are stored in JSON files.
By default the app is configures to handle english and thats all, the base translation file is in assets/i18n/.
To add translations or to know more about translations, please refere to the official documentation
lib has all our code. It has 5 folders and two files.
Let's start with files.
- lib/main.dart is the main file everyone knows, it init the app with the device's locale and init the router with go router
- lib/router.dart contains the routes for our screens, it is provided so it can be accessed without any context ! By default, the app will run the SplashScreen at startup
And the folders
- extensions contains extensions classes that are usefull. In flutter extensions are a very powerful system that makes it easy to add method to classes without breaking their contracts, so use them as much as you can
- gen contains generated translations from Slang
- models contains data classes, almost all of them are Freezed classes (or enums)
- providers contains app wide providers, like current user or theme data, all of them are Riverpod providers.
- views contains widgets and screens ! Folders are screens splited elements and widget are atomic elements that can be used anywhere in the app
The app follows certain conventions
File naaming is structued like this : [snake_case_name].[file_type].dart
.
For example:
user.model.dart
contains the user model classcurrent_user.provider.dart
contains the provider for the current usersplash.screen.dart
contains the splash screenuser_card.widget.dart
contains a UI widget that displays a card with a user- ...
For routes that needs to be shown, this file must be named [X]Screen
and expose have a declaration in AppRoute
enum
In this way, when you need to add a route in lib/router.dart
you can do this
GoRoute(
path: appRoutesPath(AppRoute.[X]),
pageBuilder: (context, state) => const MaterialPage(
child: [X]Screen(),
),
),
By default, the app is configured to follow and ignore some lint rules.
See analysis_options.yaml for the details