loadFileBytes method
Implementation
Future<Uint8List> loadFileBytes(String filePath) async {
if (!filePath.startsWith('/')) {
ByteData data = await rootBundle.load(filePath);
return data.buffer.asUint8List();
} else {
File file = File(filePath);
bool fileExists = await file.exists();
if (!fileExists) {
throw Exception('File does not exist: $filePath');
}
return await file.readAsBytes();
}
}