Merhabalar öncelikle bu döküman Flutter ile favor kullanımını kolaylaştırmak adına oluşturulmuştur.

Overview

FLAVOR KULLANIMI

Merhabalar öncelikle bu döküman Flutter ile favor kullanımını kolaylaştırmak adına oluşturulmuştur.

Flutter Projesi Oluşturma

Öncelikle klasik olarak kullandığımız Flutter proje oluşturma komutunu kullanarak projemizi oluşturuyoruz.

flutter create --org organization_name project_name

Android Kurulumu

Dosya yapısı

Android Folder Structer

Gradle dosyası yapılandırma

Aşağıdaki satırları android/apps/build.gradle dosyasının içerisine yapıştırıyoruz (tabi projenize göre özelleştirilmiş biçimde)

flavorDimensions "app"
productFlavors {
    prod {
        dimension "app"
        applicationId "com.seniorturkmen.flavor_demo"
        versionCode flutterVersionCode.toInteger()
        resValue "string", "app_name", "FlavorApp"
        versionName flutterVersionName
    }

    dev {
        dimension "app"
        applicationId "com.seniorturkmen.flavor_demo_test"
        versionCode flutterVersionCode.toInteger()
        resValue "string", "app_name", "FlavorAppTest"
        versionName flutterVersionName
    }
}

AndroidManifest.xml yapısı

android/src/main/AndroidManifest.xml dosyasının içerisinde yer alan android:label isimli alanın değerini görseldeki gibi değiştiriyoruz.

android_manifest Structer

iOS Kurulumu

iOS kurulumu yaparken xCode kullanmamız gerekiyor dolayısıyla xCode üzerinde projemizi açıyoruz.

xcode_open.png

daha sonra şemalarımızı oluşturmaya başlıyoruz.

sheme_create.png

ben burada prodve devisimli 2 adet şema oluşturuyorum.

şemalarımızı oluşturduktan sonra configurasyonlarını ayarlama ile işlemlerimize devam ediyoruz.

configurations.png

bu kısımda configurasyonlarımızı tamamladıktan sonra şemalarımız ile configurasyonlarımızı birbiri ile bağlıyoruz.

configured_scheme.png

bu işlemi hem prod hem dev şemamız için gerçekleştiriyoruz.

bağlantı işlemlerimiz bittikten sonra her app için uniqe olan bundle_iddeğişkenini her şemamıza özel ayarlıyoruz.

bundle_id_edited.png

Firebase entegrasyonu

iOS uygulamamızın firebase entegrasyonu için GoogleService-Info.plist dosyasına ihtiyaç duyulur bizler her flavor yapımıza farklı bir firebase projesi entegre etmek istersek birden fazla GoogleServices-Info.plist dosyası eklememiz gerekiyor. Bunun için xCode üzerinden devam ederek proje içerisinde configismini verdiğim bir dosya oluşturuyorum ve içerisine flavor şemalarımla aynı ismi taşıyan klasörler oluşturuyorum.

config_folder.png

daha sonra bu klasörümü xCode içerisinde tanımlıyorum.

config_folder_define.png

daha sonra proje çalıştığında ilgili dosyanın konumunu bulmasına yardımcı olan scriptimi de ekliyorum.

google_services_script.png

setopt KSH_ARRAYS BASH_REMATCH
environment="default"

# Regex to extract the scheme name from the Build Configuration
# We have named our Build Configurations as Debug-dev, Debug-prod etc.
# Here, dev and prod are the scheme names. This kind of naming is required by Flutter for flavors to work.
# We are using the $CONFIGURATION variable available in the XCode build environment to extract 
# the environment (or flavor)
# For eg.
# If CONFIGURATION="Debug-prod", then environment will get set to "prod".
if [[ $CONFIGURATION =~ -([^-]*)$ ]]; then
environment=${BASH_REMATCH[1]}
fi

echo $environment

# Name and path of the resource we're copying
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist
GOOGLESERVICE_INFO_FILE=${PROJECT_DIR}/config/${environment}/${GOOGLESERVICE_INFO_PLIST}

# Make sure GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_FILE}"
if [ ! -f $GOOGLESERVICE_INFO_FILE ]
then
echo "No GoogleService-Info.plist found. Please ensure it's in the proper directory."
exit 1
fi

# Get a reference to the destination location for the GoogleService-Info.plist
# This is the default location where Firebase init code expects to find GoogleServices-Info.plist file
PLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
echo "Will copy ${GOOGLESERVICE_INFO_PLIST} to final destination: ${PLIST_DESTINATION}"

# Copy over the prod GoogleService-Info.plist for Release builds
cp "${GOOGLESERVICE_INFO_FILE}" "${PLIST_DESTINATION}"

çalışan şemaya göre uygulama isminin değişmesi için son 1 adımımız kaldı.

user_defined_app_name.png

ve oluşturduğumuz ismi uygulama içerisinde kullanıyoruz.

app_name_change.png

uygulamamız çalıştırılmaya hazır

ilk çalıştırma

-Dev ortamı için

flutter run --target=lib/main_dev.dart --flavor=dev

-Prod ortamı için

flutter run --target=lib/main_prod.dart --flavor=prod

kodlarını girerek ilk çalıştırmayı sağlayabilirsiniz.

VsCode Setup

Flutter uygulamamızı VsCode Run & Debug tool'u aracılığıyla çalıştırmak için son bir ayar yapmamız gerekiyor.

run_and_debug.png

buradan create a launch.json file alanına tıklıyoruz. Çıkan popup üzerinden Dart & Flutter opsiyonunu seçiyoruz. ve açılan sayfadaki kodları aşağıdaki kodlarla değiştiriyoruz.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "App Name (Test)",
            "type": "dart",
            "request": "launch",
            "program": "lib/main_dev.dart",
            "args": [
                "--flavor",
                "dev",
            ]
        },
        {
            "name": "App Name",
            "type": "dart",
            "request": "launch",
            "program": "lib/main_prod.dart",
            "args": [
                "--flavor",
                "prod",
            ]
        },
        
    ]
}

Artık tool aracılığıyla daha kolay debug işlemi yapabilirsiniz.

tool_screen

You might also like...

Create a Flutter User Profile Page UI where you can access and edit your user's information within your Flutter app.

Create a Flutter User Profile Page UI where you can access and edit your user's information within your Flutter app.

Flutter Tutorial - User Profile Page UI 1/2 Create a Flutter User Profile Page UI where you can access and edit your user's information within your Fl

Dec 6, 2022

Create a Flutter User Profile Page UI where you can access and edit your user's information within your Flutter app.

Create a Flutter User Profile Page UI where you can access and edit your user's information within your Flutter app.

Flutter Tutorial - User Profile Page UI #2 Create a Flutter User Profile Page UI where you can access and edit your user's information within your Flu

Dec 15, 2022

Let's create a selectable Flutter Navigation Drawer with routing that highlights the current item within the Flutter Sidebar Menu.

Let's create a selectable Flutter Navigation Drawer with routing that highlights the current item within the Flutter Sidebar Menu.

Flutter Tutorial - Sidebar Menu & Selectable Navigation Drawer Let's create a selectable Flutter Navigation Drawer with routing that highlights the cu

Dec 26, 2022

Components that optimize Flutter fluency.(Flutter 流畅度优化的通用方案,轻松解决卡顿问题)

Components that optimize Flutter fluency.(Flutter 流畅度优化的通用方案,轻松解决卡顿问题)

Flutter fluency optimization component "Keframe" Page switching fluency improved: How to use Project depend on: Quick learning Constructor Description

Dec 30, 2022

Challenge yourself every weekend with flutter. Join me to implement challenging UI & digital designs using Flutter.

Challenge yourself every weekend with flutter. Join me to implement challenging UI & digital designs using Flutter.

Weekend With Flutter This is my new challenge. Every weekend, I want to implement challenging UI & digital designs using Flutter. you can join me with

Feb 24, 2022

Let's create a complete Flutter User Profile Page with SharedPreferences to persist the user's information in Flutter.

Let's create a complete Flutter User Profile Page with SharedPreferences to persist the user's information in Flutter.

Flutter Tutorial - User Profile & SharedPreferences Let's create a complete Flutter User Profile Page with SharedPreferences to persist the user's inf

Dec 3, 2022

Let's create a Flutter Collapsible Sidebar Menu that can collapse and expand the Navigation Drawer in Flutter.

Let's create a Flutter Collapsible Sidebar Menu that can collapse and expand the Navigation Drawer in Flutter.

Flutter Tutorial - Collapsible Sidebar Menu & Navigation Drawer Let's create a Flutter Collapsible Sidebar Menu that can collapse and expand the Navig

Jan 3, 2023

🚗 Apple CarPlay for Flutter Apps. Aims to make it safe to use apps made with Flutter in the car by integrating with CarPlay.

🚗 Apple CarPlay for Flutter Apps. Aims to make it safe to use apps made with Flutter in the car by integrating with CarPlay.

CarPlay with Flutter 🚗 Flutter Apps now on Apple CarPlay! flutter_carplay aims to make it safe to use iPhone apps made with Flutter in the car by int

Dec 26, 2022
Owner
Mustafa TÜRKMEN
->Software Developer, ->Comp. Eng. ->Flutter Developer
Mustafa TÜRKMEN
Flutter ile geliştirmiş olduğum vücut kitle indeksi programı

Vücut Kitle İndeksi Hesaplama A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to ge

Erdem KARAMAN 4 Nov 16, 2022
Aktuel-Brosurler - Flutter ile Yapılmış Aktüel Broşür Uygulaması

Merhaba, Ben Berkan Büyük ! Mobile Developer alanında kendimi geliştiriyor, kariyerimi yazılım odaklı kurmaya çalışıyorum. ⁉️ Proje Hakkında ⁉️ - Bu A

Berkan Büyük 1 Feb 16, 2022
Shared Preferences ile ekran açılma sayacı uygulaması

sayac_uygulamasi A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

null 0 Dec 29, 2021
🆙🚀 Flutter application upgrade/ Flutter App Upgrade /Flutter App Update/Flutter Update / download Plug-in

???? Flutter application upgrade/ Flutter App Upgrade /Flutter App Update/Flutter Update / download Plug-in (with notice bar progress), supports full upgrade, hot update and incremental upgrade

PengHui Li 344 Dec 30, 2022
ABC of Flutter widgets. Intended for super beginners at Flutter. Play with 35+ examples in DartPad directly and get familiar with various basic widgets in Flutter

Basic Widgets Examples This is aimed for complete beginners in Flutter, to get them acquainted with the various basic widgets in Flutter. Run this pro

Pooja Bhaumik 815 Jan 3, 2023
Minha primeira aplicação android utilizando Flutter feito no curso de Flutter da Cod3r Cursos Online. O foco dessa aplicação foi um contato inicial com o Flutter.

expenses Expenses é uma aplicação android simples feita em Flutter para controlar despesas pessoais. A aplicação consiste em: Listar transações feitas

Guilherme Teixeira Ais 2 Apr 19, 2022
Flutter Github Following Application, Using Flutter Provider and Flutter HTTP to get data from Github API.

Flutter Github Following Application Watch it on Youtube Previous Designs Checkout my Youtube channel Installation Please remember, after cloning this

Mohammad Rahmani 110 Dec 23, 2022
Flutter RSS feed parsing - A demo application of flutter which parse RSS XML contents to the flutter application

Flutter RSS feed parsing demo This is demo application of flutter which shows ho

Nyakuri Levite 3 Nov 15, 2022
Boris Gautier 1 Jan 31, 2022
Code for Flutter Talk from Flutter Vikings 2022: Custom User Interactions in Flutter

Custom User Interactions - Flutter Vikings 2022 A companion app for the Flutter Vikings 2022 talk - Custom User Interactions with Shortcuts, Intents,

Justin McCandless 9 Sep 16, 2022