AngeloAvv / flutter_flavorizr

A flutter utility to easily create flavors in your flutter application
https://pub.dev/packages/flutter_flavorizr
MIT License
469 stars 85 forks source link

Make F.appFlavor non-nullable #263

Open jakobleck opened 5 months ago

jakobleck commented 5 months ago

As far as I can tell there is no good reason for appFlavor being nullable, it shouldn't be used with a null value, right? So I'd suggest using a type Flavor instead of Flavor?. Also, probably this should be final, because why would the flavor change at runtime? Perhaps something like

enum Flavor {
  a,
  b,
}

class F {
  static late final Flavor appFlavor;

  static String get name => appFlavor.name;

  static String get title {
    switch (appFlavor) {
      case Flavor.a:
        return 'Alice';
      case Flavor.b:
        return 'Bob';
    }
  }
}

is more suitable? (Just a suggestion. Note that when failing to set the flavor - which is done first in the flavor main files - this might cause a LateInitializationError instead of silently working with a non-existent flavor name, for example.)