Quick Guide for Flutter
Published: 2023-02-26 07:58:13

## 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
```yaml
dev_dependencies: 
  flutter_launcher_name: "^<latest_version>"
  
flutter_launcher_name:
  name: "yourNewAppLauncherName"
```

Run the package with
```bash
flutter pub get
flutter pub run flutter_launcher_name:main
```

---

## Change App Icon

---

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

Add this to pubspec.yaml
```yaml
dev_dependencies:
  flutter_launcher_icons: "^<latest_version>"

flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/images/icon.png"
```


Run the package with
```bash
flutter pub get
flutter pub run flutter_launcher_icons:main
```

---

## Build and release an Android app

---

### Step By Step Procedures

- Create a upload keystore

```bash
keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
```

- Reference the keystore from the app

```bash
cd android
touch key.properties
```

Add the following to key.properties
```bash
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>
```

- 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:
```java
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
      ...
}
```
Load the key.properties file into the keystoreProperties object.

* Replace the buildTypes block:
```java
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
    }
}
```
With the signing configuration info:
```java
   signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }

   buildTypes {
       release {
           signingConfig signingConfigs.release
       }
   }
```

- Reviewing the app manifest

Review the default [App Manifest](https://developer.android.com/guide/topics/manifest/manifest-intro) 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](https://developer.android.com/guide/topics/manifest/uses-permission-element) 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 
```bash
flutter build apk
```

build aab with
```bash
flutter build appbundle
```

[Checkout the official documentation](https://docs.flutter.dev/deployment/android)