Reputation: 97
I am having weird issue images after second index is not being read. I am reading file from my app directory. Even though path is correct still it does not read. but hard coding path works. I have posted some code that i thought was necessary if you need please comment to tell me. so this is video where i copy path from exception then hard code it. There is picture too at end. sometimes it causes stackoverflow in libflutter.so but not always.
screen where error is happening (ExtraUtilities.localDocuments is Hive box)
ListView.builder(
itemCount: ExtraUtilities.localDocuments.length,
itemBuilder: (_, index) {
final LocalDocument item = ExtraUtilities.localDocuments.getAt(index);
return Column(
children: [
for (final element in item.paths) Image.file(File(element)),
Image.file(File(
'/data/user/0/com.example.healamic/app_flutter/image_picker2935344680116023215.jpg'))
],
);
},
)
ExtraUtilities
class ExtraUtilities {
static late final Box hiveBox;
static late final Box localDocuments;
static initializeHive() async {
Hive.registerAdapter(LocalDocumentAdapter());
localDocuments = await Hive.openBox('local_documents');
hiveBox = await Hive.openBox('app_data');
}
}
main.dart (here i am calling ExtraUtilities.initializeHive())
void main() async {
WidgetsFlutterBinding.ensureInitialized();
Hive.init((await getApplicationDocumentsDirectory()).path);
await ExtraUtilities.initializeNotificationPlugin();
await ExtraUtilities.initializeHive();
tz.initializeTimeZones();
tz.setLocalLocation(tz.getLocation('Asia/Kolkata'));
runApp(const Healamic());
}
In this photo path in for loop does not get load(Line No. 66) so i copied the exception path and hardcoded it(Line no.67) but then it seems to load just fine.
Exception details
======== Exception caught by image resource service ================================================
The following FileSystemException was thrown resolving an image codec:
Cannot open file, path = ' /data/user/0/com.example.healamic/app_flutter/image_picker2935344680116023215.jpg' (OS Error: No such file or directory, errno = 2)
When the exception was thrown, this was the stack:
#0 _File.open.<anonymous closure> (dart:io/file_impl.dart:356:9)
<asynchronous suspension>
#3 FileImage._loadAsync (package:flutter/src/painting/image_provider.dart:873:29)
<asynchronous suspension>
(elided 2 frames from dart:async)
Path: /data/user/0/com.example.healamic/app_flutter/image_picker2935344680116023215.jpg
Upvotes: 0
Views: 165
Reputation: 335
check it there is space before
' /data/user/0/com.example.healamic/app_flutter/image_picker293534468011602'
Upvotes: 1