chhinsras / flutter_boilerplate

Flutter boilerplate for initial project setup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flutter_boiler_plate

A flutter boiler plate code for initial project setup

What we provided and use in this project

  • A folder structure and some widgets
  • Theme switch (dark and light mode)
  • Pages
    • Login page
    • Home page
    • Some page templates

Getting Started

  1. create your own project with Android studio or flutter create command

  2. copy these files and folder into your new project

  • assets
  • lib
  • test
  • pubspec.yaml
  • analysis_options.yaml (optional)
  • README.md (optional)
  1. if you are using flavor
  • change bundle id and app name in pubspec.yaml

  • run flutter pub run flutter_flavorizr -p assets:download,assets:extract,ios:xcconfig,ios:buildTargets,ios:schema,ios:plist,assets:clean,ide:config,android:buildGradle,android:androidManifest to generate flavor config for ios and android if you're using flavor.

  • copy these files for a different launcher icon base on flavor

    • flutter_launcher_icons-prod.yaml
    • flutter_launcher_icons-dev.yaml
    • flutter_launcher_icons-staging.yaml
  1. copy .github folder if you're using github action

  2. delete all firebase dependency in pubspec.yaml if you're not using firebase

  3. run flutter pub get

  4. In [project]/android/app/build.gradle set minSdkVersion to >= 18 to use flutter_secure_storage

  5. You can copy any platform configuration setup (example: build.gradle, androidManifest) from this project into your new project

App Icon

  • replace your icon file in assets/image/app-icon.png
  • run: flutter pub run flutter_launcher_icons:main
  • if there is an error, change minSdkVersion and targetSdkVersion in android app gradle to integer instead
  • note: this command will run all flutter_launcher_icon with flavor if you have any
  • App Icon isn't dynamic by flavor in ios. you need to replace a String ""$(ASSET_PREFIX)AppIcon";" to ""$(ASSET_PREFIX)AppIcon"-$(ASSET_PREFIX);" in ios/project.pbxproj

Hive database

  1. run flutter packages pub run build_runner build to generate Hive TypeAdapter model

Integration test

flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart --flavor dev

Project folder structure

lib/src

api

  • store your repository class which extends BaseApiService
  • store your http client and http configuration

constant

  • store your constant file here such as Configuration, TextStyle, Color, Theme, Asset path, LocaleKeys, Enum, Height, Dimension.....

model

  • response: your mapping response model from api
  • request: your own model class to request api
  • db: model for hive or any database's model
  • others: custom object model

page_template

  • a template for commonly used screen or page functioanlity in an app, example: change password page, setting page....

providers

  • store your provider or riverpod class

services

  • mostly static class for some specific feature
    • example:
      • notifications service
      • database or storage service
      • auth service .....

pages

  • Each page has their own folder
  • Each folder has a .dart file and a widgets folder that contains a widget that only use specifally in this page

widgets

  • global reusable widget and divide to into folder of category such as Dialog,Card,Button,Loading.....etc

utils

  • utility function and class

assets

  • fonts

    this is where you keep your font

  • images

    this is where you keep your image asset

  • language

    this is where you keep your localization file

  • generator

    run this file with dart generator.dart to generate AppAssets class to access your images path, Example usage: Image.asset(AppAssets.icon)

About

Flutter boilerplate for initial project setup


Languages

Language:Dart 77.9%Language:C++ 13.4%Language:CMake 5.2%Language:Ruby 1.7%Language:Swift 1.2%Language:C 0.5%Language:Kotlin 0.1%Language:Objective-C 0.0%