getFlag method

  1. @override
Flag? getFlag({
  1. required String code,
  2. dynamic defaultValue,
  3. FlagType? type,
})
inherited

Implementation

@override
Flag? getFlag({required String code, defaultValue, FlagType? type}) {
  Map<String, dynamic>? flagObj;
  FlagType? flagType;

  final flagClaim = _getClaim(_featureFlagsClaim) as Map<String, dynamic>?;
  if (flagClaim == null || !flagClaim.containsKey(code)) {
    if (defaultValue == null) {
      throw KindeError(
          'Flag $code was not found, and no default value has been provided');
    }
  } else {
    flagObj = flagClaim[code];
    flagType = _flagTypeFromString(flagObj?[_flagType]);
    if (type != null &&
        flagType != null &&
        type.character != flagType.character) {
      throw KindeError('Flag $code is type $flagType - requested type $type');
    }
  }
  return Flag(code, flagType ?? type,
      flagObj != null ? flagObj[_flagValue] : defaultValue, flagObj == null);
}