GithubHelp home page GithubHelp logo

incrediblezayed / flavor_getter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from blvckpvblo/flavor_getter

0.0 1.0 0.0 111 KB

Flutter plugin to retrieve build flavors

License: BSD 3-Clause "New" or "Revised" License

Ruby 14.15% Objective-C 0.24% Kotlin 17.82% Dart 52.43% Swift 15.36%

flavor_getter's Introduction

Flavor Getter

pub package

Flavor Getter is a Flutter plugin that helps developers retrieve the current flavor (or variant) their application is running in directly from their Flutter code. This plugin currently supports iOS and Android platforms.

Installation

To use the Flavor Getter plugin in your Flutter project, follow these steps:

  1. Add the following dependency to your project's pubspec.yaml file:
dependencies:
  flavor_getter: ^1.0.0

Replace ^1.0.0 with the desired version of the Flavor Getter plugin.

  1. Run the following command to fetch the dependencies:
flutter pub get
  1. Import the Flavor Getter package in your Dart code:
import 'package:flavor_getter/flavor_getter.dart';

Getting Started

To use Flavor Getter in your Flutter project, you need to perform some setup steps depending on the platform you are targeting.

Platform Support

Platform Support
iOS โœ…
Android โœ…

Disclaimer

Please note that this readme assumes that you have already set up the flavors (or variants) for your iOS and Android projects. The instructions provided here focus on integrating the Flavor Getter plugin into your existing flavor setup. If you haven't set up flavors yet, please refer to the respective platform documentation to configure flavors for your project.

iOS Setup

  1. Open your Flutter project in Xcode by navigating to ios/Runner.xcworkspace.
  2. In Xcode, select your application target (Runner) and go to the Build Settings tab.
  3. Under the User-Defined section, add a new build setting called FLAVOR and set it to the desired flavor value for each scheme.
  4. Open the Info.plist file located in the ios/Runner directory.
  5. Add a new entry to the Information Property List with the key FLAVOR and the value $(FLAVOR). This will ensure that the flavor value is accessible in the Info.plist file.
  6. Save the Info.plist file.
  7. Build and run your application using the desired scheme and flavor.

Android Setup

  1. Open your Flutter project in Android Studio.
  2. Locate the android/app/build.gradle file.
  3. Inside the android block, ensure that the defaultConfig section contains the following line:
android {
    namespace "com.example.myapp" // Replace with your namespace
    // ...
    defaultConfig {
        // ...
        applicationId "com.example.myapp" // Replace with your applicationId; make sure it's similar to namespace
        // ...
    }
}

The applicationId should match the package name defined in your AndroidManifest.xml file. 4. To add flavors, add the following lines to the android block:

flavorDimensions "default"

productFlavors {
    dev {
        applicationIdSuffix ".dev"  // com.example.myapp.dev
    }
    prod {
        applicationIdSuffix ".prod"  // com.example.myapp.prod
    }
}

Customize the flavor names (dev and prod) and the applicationIdSuffixes (.dev and .prod) to match your desired flavors.

Usage

To retrieve the current flavor in your Flutter code, you can use the getFlavor() function.

import 'package:flavor_getter/flavor_getter.dart';

void main() async {
	String currentFlavor = await FlavorGetter().getFlavor();
	print('Running in flavor: $currentFlavor');
}

Example

For a complete example of using Flavor Getter, please refer to the example directory of this plugin.

Issues and Contributions

Please report any issues or bugs you encounter by opening an issue on the GitHub repository. Contributions are also welcome via pull requests.

flavor_getter's People

Contributors

blvckpvblo avatar incrediblezayed avatar

Watchers

 avatar

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.