Coder Social home page Coder Social logo

icapps / flutter-template Goto Github PK

View Code? Open in Web Editor NEW
166.0 14.0 40.0 24.67 MB

A Flutter Template to get started quickly

License: MIT License

Kotlin 0.11% Ruby 1.82% Swift 0.06% Objective-C 0.01% Dart 94.19% Python 2.45% Shell 0.74% HTML 0.63%

flutter-template's Introduction

Flutter Template

Build Status Coverage Status MIT license

  • dependency injection (injectable/get it)
  • network layer (dio)
  • network logging (niddler, dio)
  • viewmodels (provider)
  • translations (icapps translations)
  • json serialization (json_serializable)
  • different environments
  • themes
  • navigator
  • linting (flutter analyze)

Update the translations

A custom dart program is used for updating the translations

https://pub.dev/packages/icapps_translations

Update your config in the pubspec.yaml

icapps_translations:
  api_key: 'enter-your-api-key'
  default_language: 'nl'
  languages: ['en', 'nl']

Add your locale folder to your flutter config

flutter:
  assets:
    - assets/locale/

Command to run to update the translations

fvm flutter packages pub run icapps_translations

Json Serializable & Kiwi

fvm flutter packages pub run build_runner build --delete-conflicting-outputs
fvm flutter packages pub run build_runner watch

Environments

--release is not available for emulators. Performance will be better

Dev, Debug

fvm flutter run --flavor dev -t lib/main.dart

fvm flutter run --release --flavor dev -t lib/main.dart

Dummy

Note: a hot reload is required after launch to use the correct launch file.

fvm flutter run --flavor dev -t lib/main_dummy.dart

fvm flutter run --release --flavor dev -t lib/main_dummy.dart

Alpha

fvm flutter run --flavor alpha -t lib/main_alpha.dart

fvm flutter run --release --flavor alpha -t lib/main_alpha.dart

Beta

fvm flutter run --flavor beta -t lib/main_beta.dart

fvm flutter run --release --flavor beta -t lib/main_beta.dart

Prod, Release

fvm flutter run --flavor prod -t lib/main_prod.dart

fvm flutter run --release --flavor prod -t lib/main_prod.dart

Niddler

https://github.com/Chimerapps/niddler_dart

Niddler is a network tracing tool written by Nicola Verbeeck. An Android Studio and Intelij plugin is available to download in the plugin store. (https://plugins.jetbrains.com/plugin/10347-niddler - https://github.com/Chimerapps/niddler-ui) Niddler is also available for Android & Java (OkHttp: https://github.com/icapps/niddler)

Linting

To check your code matches our linting. The analysis_options.yaml contains all our code checks.

flutter analyze

Testing

In order to run our test we need to run

fvm flutter test

If we want to update our golden files we need to run

fvm flutter test --update-goldens

Fastlane

Fastlane is used for building iOS and Android

Transform this template project

Rename this project

This script will run a dart script. The dart script itself will ask you some input to complete the full rename

./tool/rename_project.sh

Add provisioning files

Add the provisioning profiles in the ios/provisioning/ folder. The naming of the files should be the same as provided in the ios/Configuration/{flavor}.xcconfig files (underscore will be replaced with a space in the configuration files)

Firebase

To setup firebase you will need to create a new firebase project with 8 new apps, 1 for each flavor on both iOS and Android.

When creating the iOS apps on firebase you will be able to download a GoogleService-Info.plist file which you will need to rename according to the flavor you just created an app for e.g.: You just created the iOS App for the Dev flavor so your file should be named GoogleService-Info-dev.plist. Each .plist file you download from firebase needs to be placed in the ios/Configuration/GoogleService/ folder. Whenever the project is run with a different flavor from the currently active flavor, it will automatically copy the correct GoogleService-Info-{flavor}.plist file into the ios/Runner/ folder.

When creating the Android apps you will be able to download a google-services.json file, you only need to download this file once at the end of the last Android app setup on firebase. This .json file contains all the configurations for the 4 Android apps which you just created. Add the .json file in the android/app/src/ folder.

Languages

Configure the required languages in Xcode

icapps Translations

Update the translations.py file (edit the todos)

Obfuscation

Obfuscation is enabled by default when using fastlane for building. The symbol files are stored in ./build/debug-info/#{options[:flavor]}

Important: Add the following regex to jenkins configuration to also archive the symbol files

**/*.symbols

Icons

Replace the files in the assets_launcher_icons/** folder.

You can also change the adaptive_icon_background in the flutter_launcher_icons-{flavor}.yaml (currently "#CB2E63") (only available for Android 8.0 devices and above)

After this, run the following command

fvm flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-dev.yaml

Common issues

No flavor provided

Add a flavor to your configuration. Extra info can be found in this issue -> #3

Questions?

For question contact William Verhaeghe

Finish

When you have completed this readme. Replace it with the readme for your project.

flutter-template's People

Contributors

ikbendewilliam avatar jorre127 avatar nicolaverbeeck avatar rwillemsandroid avatar vanlooverenkoen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter-template's Issues

Disable ipad support by default

Because most apps only support mobile we should disable ipad by default. If for a specific project we do need ipad support the developer should enable it himself

Use your viewmodel for getting correct value in a list

ListView.builder(
                padding: const EdgeInsets.all(ThemeDimens.padding16),
                itemCount: value.data.length,
                itemBuilder: (context, index) {
                  final item = value.data[index];
                  return UserRow(
                    title: item.name,
                    titleIcon: Icons.person,
                    subtitle: item.address.street,
                    subtitleIcon: Icons.location_city,
                    onClick: value.onUserClicked,
                  );
                },
              );

item.location_city & item.person should come from your viewmodel

Add support for Flavored names

Add support for configurable Names per Flavor

Flutter Template Debug
Flutter Template Alpha
Flutter Template Beta
Flutter Template

Wrong folder structure

In the android template, the folder structure states: 'flutte_template' instead of 'flutter_template'. This conflicts with the package definition of MainActivity.kt

Niddler error

After cloning the repo, running "flutter packages get" I tried to run the app but I got this error:

lib/niddler.dart:13:3: Error: Getter not found: 'NiddlerInjector'.
  NiddlerInjector.install(niddler);
  ^^^^^^^^^^^^^^^

To fix this I had to replace this line:

NiddlerInjector.install(niddler);

with

niddler.install()

Update to androidx

Update the android project to use android x instead of the support libraries

CombiningSmartInterceptor is never used

Dio provideDio(CombiningSmartInterceptor interceptor) {
  final dio = Dio();
  dio.options.baseUrl = FlavorConfig.instance.values.baseUrl;
  dio.interceptors.add(interceptor);
  return dio;
}
@Register.singleton(NetworkLogInterceptor)
@Register.singleton(NetworkAuthInterceptor)
@Register.singleton(NetworkErrorInterceptor)
@Register.singleton(NetworkRefreshInterceptor)

Disable scalable fonts.

Add this around in the build method of the mainnavigator

    final mediaQuery = MediaQuery.of(context);
    return MediaQuery(
      data: mediaQuery.copyWith(textScaleFactor: 1),
      child: ,
    );

allowBackup should be false by default

By default the app keeps it's saved values even if the app was removed and reinstalled. For most cases we don't want that. so allowBackup should be set to false for android

bump version number in fastlane

Replace BUILD_NR = ENV["BUILD_NUMBER"] with this:

BUMP_BUILD_NR = 0
BUILD_NR = ENV["BUILD_NUMBER"] || ''

if BUILD_NR == ''
  sh("echo","No build nr set")
else
  BUILD_NR = Integer(BUILD_NR) + BUMP_BUILD_NR
  sh("echo","New build nr: #{BUILD_NR}")
end

Fastlane ensure latest flutter version is installed on jenkins

Set to the latest version


FLUTTER_VERSION = '1.20.1' # Configure if you want to use a specific version.
FLUTTER_CHANNEL = 'stable' # Configure if you want to use a specific channel.


private_lane :ensureFlutterVersion do
    #sh("flutter", "channel", FLUTTER_CHANNEL)

    if FLUTTER_VERSION == ""
        sh("echo", "No specific version specified. We will use the latest version")
        sh("flutter", "upgrade", "--force")
    else
        # First we check if the current version is the specified version
        begin
            sh("flutter --version | grep -o 'Flutter #{FLUTTER_VERSION}'")
        rescue => ex
            sh("echo", "Current version is not v#{FLUTTER_VERSION}, So we will first upgrade")
            sh("flutter", "upgrade", "--force")
        end

        # We check again if we are not on the specified version.
        begin
            sh("flutter --version | grep -o 'Flutter #{FLUTTER_VERSION}'")
        rescue => ex
            # We are not yet on the specified version so let's downgrade.
            begin
               sh("flutter", "downgrade", "v#{FLUTTER_VERSION}")
            rescue => ex
               raise ex unless ex.message.include?('There is no previously recorded version for channel ')
               sh("echo", "We will use the latest version of flutter anyway")
               sh("flutter", "upgrade", "--force")
            end
        end
    end
    sh("flutter", "doctor", "-v")
end

Add wrapped logger to the logger class

void printWrapped(String text) {
  final pattern = RegExp('.{1,800}'); // 800 is the size of each chunk
  pattern.allMatches(text).forEach((match) => print(match.group(0)));
}

Test setup

Testup setup should be included in the template as well.

Add appbundle lane to fastlane

private_lane :buildAppBundleAndroid do |options|
    Dir.chdir ".." do
      sh("flutter", "build", "appbundle", "--release", "--flavor", options[:flavor], "-t" "lib/main_#{options[:flavor]}.dart", "--build-number=#{BUILD_NR}")    # Build the application
    end
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.