appendAsset method
Implementation
@override
Future<Either<Failure, Unit>> appendAsset(String assetPath) async {
try {
final content = _yaml.readAsStringSync();
final assetTagExists = content.contains('assets:');
if (assetTagExists) {
final replaceContent = [
'assets:',
' - $assetPath/',
].join('\n');
_yaml.writeAsStringSync(content.replaceAll('assets:', replaceContent));
} else {
final appendContent = [
'',
' assets:',
' - $assetPath/',
].join('\n');
_yaml.writeAsStringSync(appendContent, mode: FileMode.append);
}
return const Right(unit);
} catch (e) {
return Left(UnknownFailure(cause: e.toString()));
}
}