newAsset static method

Future<void> newAsset(
  1. String newAsset
)

this function will =>

  1. create folder in assets/image
  2. add this asset in pubspec.yaml and run pub get command

Implementation

static Future<void> newAsset(String newAsset) async {
  final newImageFolder = _getDir(newAsset, _imagesFolder);
  if (newImageFolder.existsSync()) {
    print('$newAsset is exists before');
    return;
  }
  newImageFolder.createSync(recursive: true);
  final yamlContent = await _yamlFile.readAsString();
  final newYamlContent = yamlContent.replaceAll('''assets:''', '''
assets:
  - assets/images/$newAsset/''');
  await _yamlFile.writeAsString(newYamlContent);
  await Shell().run('''flutter pub get''');
  await git('new asset $newAsset', true);
}