add asset validation

This commit is contained in:
hannathkadher
2025-01-09 16:18:19 +04:00
parent 097e70b906
commit 67516817ec
3 changed files with 36 additions and 14 deletions

View File

@ -0,0 +1,15 @@
import 'package:flutter/services.dart';
class AssetValidator {
static Future<bool> isValidAsset(String? assetPath) async {
if (assetPath == null || assetPath.isEmpty) {
return false;
}
try {
await rootBundle.load(assetPath);
return true;
} catch (_) {
return false;
}
}
}