loadConfigFromPubSpec static method

FlutterLauncherIconsConfig? loadConfigFromPubSpec(
  1. String prefix
)

Loads flutter launcher icons config from pubspec.yaml file

Implementation

static FlutterLauncherIconsConfig? loadConfigFromPubSpec(String prefix) {
  try {
    final pubspecFile = File(path.join(prefix, constants.pubspecFilePath));
    if (!pubspecFile.existsSync()) {
      return null;
    }
    final pubspecContent = pubspecFile.readAsStringSync();
    return yaml.checkedYamlDecode<FlutterLauncherIconsConfig?>(
      pubspecContent,
      (json) {
        // TODO(RatakondalaArun): add support for new scheme https://github.com/fluttercommunity/flutter_launcher_icons/issues/373
        return json == null || json['flutter_icons'] == null
            ? null
            : FlutterLauncherIconsConfig.fromJson(json['flutter_icons']);
      },
      allowNull: true,
    );
  } on yaml.ParsedYamlException catch (e) {
    throw InvalidConfigException(e.formattedMessage);
  } catch (e) {
    rethrow;
  }
}