readFile<T> static method
Attempts to read a File from the specified filePath
, and parse it with
the specified parser
. Common FileParser implementations are available
from FileParsers. If the file doesn't exist, throws a FileSystemException
Implementation
static T readFile<T>({required File file, required FileParser<T> parser}) {
if (!file.existsSync()) {
throw FileSystemException('File not found', file.path);
}
return parser(file.readAsBytesSync());
}