Привет, я использую плагин https://pub.dev/packages/gallery_saver, и в моем приложении есть изображения ресурсов, которые я пытаюсь сохранить в галерее телефонов. Я делаю что-то подобное, но не могу. Кто-нибудь, пожалуйста, помогите мне
void _saveNetworkImage() async {
Directory tempDir = await getTemporaryDirectory();
String tempPath = tempDir.path;
String path = tempPath + '/' + widget.imagePath; // widget.imgPath = "assets/images/my image.jpg";
print('ddd' + path);
GallerySaver.saveImage(path).then((bool success) {
setState(() {
print('Image is saved');
});
});
}
}
Я вызываю функцию ablove как:
floatingActionButton: FloatingActionButton.extended(
onPressed: _saveNetworkImage,
icon: Icon(Icons.save),
label: Text('Gallery'),
backgroundColor: Colors.white54,
foregroundColor: Colors.black,
)
Здесь моя функция работает, но выдает ошибку
D/ViewRootImpl@cbdf65[MainActivity]( 3518): ViewPostIme pointer 1
I/flutter ( 3518): path/data/user/0/com.thesachin.template/cache
I/flutter ( 3518): ddd/data/user/0/com.thesachin.template/cache/assets/images/aaj nhi kal karenge.jpg
E/AndroidRuntime( 3518): FATAL EXCEPTION: DefaultDispatcher-worker-1
E/AndroidRuntime( 3518): Process: com.thesachin.template, PID: 3518
E/AndroidRuntime( 3518): java.io.FileNotFoundException: /data/user/0/com.thesachin.template/cache/assets/images/aaj nhi kal karenge.jpg (No such file or directory)
E/AndroidRuntime( 3518): at java.io.FileInputStream.open0(Native Method)
E/AndroidRuntime( 3518): at java.io.FileInputStream.open(FileInputStream.java:231)
E/AndroidRuntime( 3518): at java.io.FileInputStream.<init>(FileInputStream.java:165)
E/AndroidRuntime( 3518): at carnegietechnologies.gallery_saver.FileUtils.getBytesFromFile(FileUtils.kt:216)
E/AndroidRuntime( 3518): at carnegietechnologies.gallery_saver.FileUtils.insertImage(FileUtils.kt:47)
E/AndroidRuntime( 3518): at carnegietechnologies.gallery_saver.GallerySaver$saveMediaFile$1$success$1.invokeSuspend(GallerySaver.kt:69)
E/AndroidRuntime( 3518): at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime( 3518): at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238)
E/AndroidRuntime( 3518): at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
E/AndroidRuntime( 3518): at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
E/AndroidRuntime( 3518): at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742)
D/ViewRootImpl@cbdf65[MainActivity]( 3518): MSG_WINDOW_FOCUS_CHANGED 0 1
D/InputMethodManager( 3518): prepareNavigationBarInfo() DecorView@460d1a9[MainActivity]
D/InputMethodManager( 3518): getNavigationBarColor() -855310
I/Process ( 3518): Sending signal. PID: 3518 SIG: 9
Lost connection to device.