Skip to content

quentin7b/flutter_bootstrap

Repository files navigation

flutter_bootstrap_app

A Flutter Bootstrap Project

Getting Started

This project is a starting point for a Flutter application. It has built in dependencies pre configured to handle multiple things

Start using it

  1. Git clone this project
  2. Run dart init.dart and follow instructions to configure package name
  3. Run flutter pub get
  4. You're good to go

Structure & Dependencies

Here is the list of all dependencies that are preconfigures for the project and the architecture of its folders

Dependencies

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

Structure

There are two main folders that are pre-structures, assets and lib

Assets

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

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

Conventions

The app follows certain conventions

File naming

File naaming is structued like this : [snake_case_name].[file_type].dart.

For example:

  • user.model.dart contains the user model class
  • current_user.provider.dart contains the provider for the current user
  • splash.screen.dart contains the splash screen
  • user_card.widget.dart contains a UI widget that displays a card with a user
  • ...

Specifics

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(),
    ),
),

Analysis

By default, the app is configured to follow and ignore some lint rules.

See analysis_options.yaml for the details