add method
Implementation
Future<void> add(
String path, {
bool nowWrite = true,
bool isFailTip = true,
}) async {
final AssetItem? asset = ImageAssetItem.exts.contains(context.extension(path).substring(1))
? await ImageAssetItem.readFile(path, lib, options)
: await AssetItem.readFile(path, lib, options);
if (asset == null) {
if (isFailTip) logger.warning(className, 'add失败,asset中不存在$path', StackTrace.current);
} else {
final AssetItem? oldAsset = list[path];
if (oldAsset?.hash == asset.hash) return;
list[path] = asset;
await Future.wait([
asset.dustbinExists.then((bool exists) async {
if (exists) await File(asset.dustbinPath).delete();
}),
if (nowWrite) writeListFile(),
]);
}
}