hasExtension method
Checks whether the asset’s path ends with any of the provided extensions.
This is useful for filtering specific types of files
(e.g., .json
, .yaml
, .properties
).
Example
if (resource.hasExtension([".json", ".yaml"])) {
print("This is a supported config file");
}
Implementation
@override
bool hasExtension(List<String> exts) {
if(exists()) {
return exts.any((e) => _asset!.getFilePath().containsIgnoreCase(e));
}
throw _throwIfNotFound();
}