DEV Community

Mohammed Shaheem P
Mohammed Shaheem P

Posted on

Quick Guide for Flutter

Change App Display Name


Instead of changing the name in android, ios, etc.. separately, Use the package flutter_launcher_name

Add this to pubspect.yaml

dev_dependencies: 
  flutter_launcher_name: "^<latest_version>"

flutter_launcher_name:
  name: "yourNewAppLauncherName"
Enter fullscreen mode Exit fullscreen mode

Run the package with

flutter pub get
flutter pub run flutter_launcher_name:main
Enter fullscreen mode Exit fullscreen mode

Change App Icon


Instead of changing the icon in android, ios, etc.. separately, Use the package flutter_launcher_icons

Add this to pubspec.yaml

dev_dependencies:
  flutter_launcher_icons: "^<latest_version>"

flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/images/icon.png"
Enter fullscreen mode Exit fullscreen mode

Run the package with

flutter pub get
flutter pub run flutter_launcher_icons:main
Enter fullscreen mode Exit fullscreen mode

Build and release an Android app


Step By Step Procedures

  • Create a upload keystore
keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
Enter fullscreen mode Exit fullscreen mode
  • Reference the keystore from the app
cd android
touch key.properties
Enter fullscreen mode Exit fullscreen mode

Add the following to key.properties

storePassword=<upload-keystore-password>
keyPassword=<upload-keystore-password>
keyAlias=upload
storeFile=<location of the key store file, such as /Users/<user name>/upload-keystore.jks>
Enter fullscreen mode Exit fullscreen mode
  • Configure signing in gradle

Configure gradle to use your upload key when building your app in release mode by editing the [project]/android/app/build.gradle file.

  • Add the keystore information from your properties file before the android block:
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
      ...
}
Enter fullscreen mode Exit fullscreen mode

Load the key.properties file into the keystoreProperties object.

  • Replace the buildTypes block:
buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now,
        // so `flutter run --release` works.
        signingConfig signingConfigs.debug
    }
}
Enter fullscreen mode Exit fullscreen mode

With the signing configuration info:

   signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }

   buildTypes {
       release {
           signingConfig signingConfigs.release
       }
   }
Enter fullscreen mode Exit fullscreen mode
  • Reviewing the app manifest

Review the default App Manifest file, AndroidManifest.xml, located in [project]/android/app/src/main and verify that the values are correct, especially the following:

application Edit the android:label in the application tag to reflect the final name of the app. uses-permission Add the android.permission.INTERNET permission if your application code needs Internet access. The standard template does not include this tag but allows Internet access during development to enable communication between Flutter tools and a running app.

  • Build APK or AAB

build APK with

flutter build apk
Enter fullscreen mode Exit fullscreen mode

build aab with

flutter build appbundle
Enter fullscreen mode Exit fullscreen mode

Checkout the official documentation

Top comments (0)