flutter_flavorizr icon indicating copy to clipboard operation
flutter_flavorizr copied to clipboard

Make F.appFlavor non-nullable

Open jakobleck opened this issue 1 year ago • 0 comments

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.)

jakobleck avatar May 27 '24 09:05 jakobleck