Multi App Flavor

Pub Version License: MIT

A Flutter package to easily manage multi-tenant applications (Flavors) with support for custom configurations, themes, and assets per flavor.

Repository: https://github.com/kedirinesia/Multi-App-Flavor

Features

  • Singleton Configuration: Easy access to current flavor state anywhere in the app.
  • Flavor Independent UI: Build unrelated UI components for different apps using FlavorBuilder.
  • Visual Indicator: FlavorBanner to show current environment (Dev/Staging) on top of the app.
  • Custom Values: Store API endpoints, API Keys, and other constants specific to a flavor.

Getting Started

  1. Add dependency to pubspec.yaml:
dependencies:
  multi_app_flavor:
    path: ./ # or git/pub path
  1. Initialize FlavorConfig in your main.dart (create separate main files for each flavor):

lib/main_app1.dart

void main() {
  FlavorConfig(
    flavor: Flavor.app1,
    name: 'Application 1',
    color: Colors.blue,
    values: {
      'baseUrl': 'https://app1.com/api',
    },
  );
  runApp(MyApp());
}
  1. Use FlavorBuilder in your code:
FlavorBuilder(
  onApp1: (_) => App1Logo(),
  onApp2: (_) => App2Logo(),
  orElse: (_) => DefaultLogo(),
)

Running Flavors

Run the specific target file:

flutter run -t lib/apps/app1/main.dart
flutter run -t lib/apps/app2/main.dart

Libraries

multi_app_flavor