findAssetPaths method

Future<List<String>> findAssetPaths(
  1. String projectPath
)

Implementation

Future<List<String>> findAssetPaths(String projectPath) async {
  final pubspec = await readPubspec(projectPath);

  if (pubspec == null ||
      pubspec['flutter'] == null ||
      pubspec['flutter']['assets'] == null) {
    return [];
  }

  try {
    return (pubspec['flutter']['assets'] as YamlList)
        .map((e) => path.join(projectPath, e.toString()))
        .toList();
  } catch (e) {
    throw AssetOptException('Invalid assets configuration in pubspec.yaml');
  }
}