gpt4 book ai didi

dart - 无法打开文件,路径 = 'file:///path'(操作系统错误 : No such file or directory, errno = 2)

转载 作者:IT王子 更新时间:2023-10-29 06:46:24 25 4
gpt4 key购买 nike

您好,我正在尝试使用图像库减小从图库中选取的图像尺寸在尝试我遇到这样的错误时

E/flutter (13796): [ERROR:lib/tonic/logging/dart_error.cc(16)]    Unhandled exception:
E/flutter (13796): FileSystemException: Cannot open file, path = 'file:///storage/emulated/0/WhatsApp/Media/WhatsApp%20Images/IMG-20171016-WA0020.jpg' (OS Error: No such file or directory, errno = 2)
E/flutter (13796): #0 _File.throwIfError (file_impl.dart:618)
E/flutter (13796): #1 _File.openSync (file_impl.dart:473)
E/flutter (13796): #2 _File.readAsBytesSync (file_impl.dart:533)
E/flutter (13796): #3 _AddNewUserState.qqq (/data/data/com.prayuta.chitfunds/cache/chitfundsUNFPRG/chitfunds/lib/users.dart:420:97)
E/flutter (13796): <asynchronous suspension>
E/flutter (13796): #4 _AddNewUserState.build.<anonymous closure> (/data/data/com.prayuta.chitfunds/cache/chitfundsUNFPRG/chitfunds/lib/users.dart:686:19)
E/flutter (13796): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (13796): #6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:149:9)
E/flutter (13796): #7 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:119:7)
E/flutter (13796): #8 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (13796): #9 BindingBase&SchedulerBinding&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:147:20)
E/flutter (13796): #10 BindingBase&SchedulerBinding&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
E/flutter (13796): #11 BindingBase&SchedulerBinding&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (13796): #12 BindingBase&SchedulerBinding&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
E/flutter (13796): #13 BindingBase&SchedulerBinding&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
E/flutter (13796): #14 _invoke1 (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:100)
E/flutter (13796): #15 _dispatchPointerDataPacket (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:58)

谁能帮忙,我的代码是这样的

import 'package:image/image.dart' as convertinglib;
File imageFile = await ImagePicker.pickImage();
convertinglib.Image image = convertinglib.decodeImage(new Io.File(imageFile.uri.toString()).readAsBytesSync());
convertinglib.Image thumbnail = convertinglib.copyResize(image, 120);

最佳答案

我想问题是将图像 URI 作为字符串传递。有一个 fromUri 构造函数,您可以在其中传递文件 URI。

尝试使用

    new Io.File.fromUri(imageFile.uri)

代替

    new Io.File(imageFile.uri.toString())

关于dart - 无法打开文件,路径 = 'file:///path'(操作系统错误 : No such file or directory, errno = 2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46782521/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com