I'm trying to read an image in flutter into a Uint8List but it keeps returning file not found even after ive added the asset path in pubspec file
Future<Uint8List> pick_default_image() async {
Uint8List img = (await rootBundle.load('assets/logo_oinkgram.png')).buffer.asUint8List();
return img;
}
pickImage(ImageSource source) async {
final ImagePicker _imagePicker = ImagePicker();
XFile? _file = await _imagePicker.pickImage(source: source);
if (_file != Null) {
return await _file!.readAsBytes();
}
}
//The variable
Future<Uint8List> _image = pick_default_image();
Here's the code and error i'm getting: Code and error\
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PathNotFoundException: Cannot open file, path = 'assets/logo_oinkgram.png' (OS Error: No such file or directory, errno = 2)
any suggestions on what do I do?
edit:
I've updated the functions but the functions applied on the variable are now of different types Future and Uint8List