import 'package:boilerplate/core/enum/flavor.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import '../utils/print_utils.dart';
import 'flavor_setting.dart';

class FlavorManager {
  static getFlavorSetting() async {
    const platform = MethodChannel('native');
    var flavor = await platform.invokeMethod<String?>('getFlavor');

    if (kDebugMode) {
      print('STARTED WITH FLAVOR $flavor');
    }

    if (flavor == Flavors.dev.value) {
      return FlavorSettings.dev().appSetting;
    } else if (flavor == Flavors.uat.value) {
      return FlavorSettings.sit().appSetting;
    } else if (flavor == Flavors.uat.value) {
      return FlavorSettings.uat().appSetting;
    } else if (flavor == Flavors.prd.value) {
      return FlavorSettings.prd().appSetting;
    } else {
      throw Exception("Unknown flavor: $flavor");
    }
  }
}
