getFlavorNameFromFileName static method

String getFlavorNameFromFileName(
  1. String fileName
)

Extracts the flavor name from a valid flavor config filename

Throws an exception if the filename is not a valid flavor config filename

Implementation

static String getFlavorNameFromFileName(String fileName) {
  final flavorMatch =
      RegExp(r'^flutter_native_splash-(.+)\.yaml$').firstMatch(fileName);

  final flavorName = flavorMatch?.group(1);

  if (flavorName == null) {
    throw Exception('Invalid flavor config filename: $fileName');
  }

  return flavorName;
}