Skip to content
Snippets Groups Projects
README.md 6.46 KiB
Newer Older
anfeichtinger's avatar
anfeichtinger committed
# Flutter Production Boilerplate
## A flutter project containing bloc, flutter_lints, hive, easy_translations and more!
anfeichtinger's avatar
anfeichtinger committed

This repository is the starting point for my personal projects. If you have any suggestions or
improvements feel free to let me know. The project strives to implement best practices recommended
by Google and other developers. These best practices include but are not limited to:
anfeichtinger's avatar
anfeichtinger committed

- Using BLOC & Cubit for state management.
- Using Flutter Lints for stricter linting rules.
anfeichtinger's avatar
anfeichtinger committed
- Using Hive for platform independent storage that also works for web.
- Project structure, const constructors, extracted widgets and many more...

## Installation

This repository requires [Flutter](https://flutter.dev/docs/get-started/install) to be installed and
present in your development environment.
anfeichtinger's avatar
anfeichtinger committed

anfeichtinger's avatar
anfeichtinger committed
Clone the project and enter the project folder.
anfeichtinger's avatar
anfeichtinger committed
```sh
anfeichtinger's avatar
anfeichtinger committed
git clone https://github.com/anfeichtinger/flutter_production_boilerplate.git
cd flutter_production_boilerplate
anfeichtinger's avatar
anfeichtinger committed
```

Andreas Feichtinger's avatar
Andreas Feichtinger committed
You can remove the screenshots located in [assets/img/](./assets/img).

anfeichtinger's avatar
anfeichtinger committed
Get the dependencies.
anfeichtinger's avatar
anfeichtinger committed
```sh
anfeichtinger's avatar
anfeichtinger committed
flutter pub get
anfeichtinger's avatar
anfeichtinger committed
```

Run the app via command line or through your development environment. (optional)
anfeichtinger's avatar
anfeichtinger committed
```sh
anfeichtinger's avatar
anfeichtinger committed
flutter run lib/main.dart
```

## Pub packages

This repository makes use of the following pub packages:

| Package                                                             | Version | Usage                                                |
|---------------------------------------------------------------------|---------|------------------------------------------------------|
| [Bloc](https://pub.dev/packages/bloc)                               | ^8.1.0  | State management*                                    |
| [Flutter Bloc](https://pub.dev/packages/flutter_bloc)               | ^8.1.1  | State management*                                    |
| [Hydrated Bloc](https://pub.dev/packages/hydrated_bloc)             | ^9.0.0  | Persists Bloc state with Hive                        |
| [Equatable](https://pub.dev/packages/equatable)                     | ^2.0.5  | Easily compare custom classes, used for Bloc states* |
| [Flutter Lints](https://pub.dev/packages/flutter_lints)             | ^2.0.1  | Stricter linting rules                               |
| [Path Provider](https://pub.dev/packages/path_provider)             | ^2.0.11 | Get the save path for Hive                           |
| [Flutter Displaymode](https://pub.dev/packages/flutter_displaymode) | ^0.5.0  | Support high refresh rate displays                   |
| [Easy Localization](https://pub.dev/packages/easy_localization)     | ^3.0.1  | Makes localization easy                              |
| [Hive](https://pub.dev/packages/hive)                               | ^2.2.3  | Platform independent storage.                        |
| [Url Launcher](https://pub.dev/packages/url_launcher)               | ^6.1.7  | Open urls in Browser                                 |
| [Ionicons](https://pub.dev/packages/ionicons)                       | ^0.2.2  | Modern icon library                                  |
anfeichtinger's avatar
anfeichtinger committed
> \* Recommended to keep regardless of your project

## Using this package as a starting point

After following the installation steps you can customize your project. The screens and widgets that
are inside the project can be easily replaced or removed. They are supposed to give the user a basic
understanding of the relations between widgets and some good practices. The code includes some
comments with documentation and examples. The examples can be found by searching for "Example:"
inside the project files.
anfeichtinger's avatar
anfeichtinger committed

anfeichtinger's avatar
anfeichtinger committed
### Changing the package and app name
anfeichtinger's avatar
anfeichtinger committed

You can follow the instructions in this [Stackoverflow issue](https://stackoverflow.com/a/51550358).

anfeichtinger's avatar
anfeichtinger committed
### Theme
anfeichtinger's avatar
anfeichtinger committed

You can customize your brand colors in the [lib/config/theme.dart](./lib/config/theme.dart) file.
The project uses colors from [TailwindCSS](https://tailwindcss.com/docs/customizing-colors). As
primary swatch the indigo color palette is used while for the text the gray color palette is used.
Feel free to replace those values with your own. In order to get a smooth transition for the text
colors it is necessary to override each text type in the TextTheme.
anfeichtinger's avatar
anfeichtinger committed

anfeichtinger's avatar
anfeichtinger committed
### Removing unwanted packages
anfeichtinger's avatar
anfeichtinger committed

If a package is not listed, then removing it from [pubspec.yaml](./pubspec.yaml) as well as all
imports and uses should be enough. This is required for removing every packages, the following
instructions are an addition to that.
anfeichtinger's avatar
anfeichtinger committed

#### Flutter Lints
anfeichtinger's avatar
anfeichtinger committed

Delete the [analysis_options.yaml](./analysis_options.yaml) file. As an alternative you can modify
the rules in this file or use a different package like [Lint](https://pub.dev/packages/lint).
anfeichtinger's avatar
anfeichtinger committed

anfeichtinger's avatar
anfeichtinger committed
#### Easy Localization
anfeichtinger's avatar
anfeichtinger committed

Remove the [assets/translations](./assets/translations) folder. Go
to [ios/Runner/Info.plist](./ios/Runner/Info.plist) and remove the following code:
anfeichtinger's avatar
anfeichtinger committed

```
<key>CFBundleLocalizations</key>
<array>
	<string>en</string>
   	<string>de</string>
</array>
```

anfeichtinger's avatar
anfeichtinger committed
#### Url Launcher
anfeichtinger's avatar
anfeichtinger committed

For iOS go to [ios/Runner/Info.plist](./ios/Runner/Info.plist) and remove the following code:

```
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>https</string>
  <string>http</string>
</array>
```

For Android you can take a look at this [Stackoverflow issue](https://stackoverflow.com/a/65082750)
for more information. Go
to [android/app/src/AndroidManifest.xml](./android/app/src/main/AndroidManifest.xml) and remove the
following code:
anfeichtinger's avatar
anfeichtinger committed

```
<queries>
     <intent>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="https" />
    </intent>
</queries>
```
anfeichtinger's avatar
anfeichtinger committed

anfeichtinger's avatar
anfeichtinger committed
## Screenshots

#### Light Theme

| Home Light                                                                     | Info Light                                                                    |
|--------------------------------------------------------------------------------|-------------------------------------------------------------------------------|
| ![Home Light](./assets/img/home_light.png "The home page with a light theme.") | ![Info Light](./assets/img/info_light.png "The home page with a dark theme.") |
anfeichtinger's avatar
anfeichtinger committed

#### Dark Theme

| Home Dark German                                                             | Info Dark German                                                            |
|------------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| ![Home Dark](./assets/img/home_dark.png "The info page with a light theme.") | ![Info Dark](./assets/img/info_dark.png "The info page with a dark theme.") |
anfeichtinger's avatar
anfeichtinger committed

anfeichtinger's avatar
anfeichtinger committed
## License

Andreas Feichtinger's avatar
Andreas Feichtinger committed
MIT