【发布时间】:2020-09-14 06:48:15
【问题描述】:
//main.dart
// The declared uint8list turns gray (android studio).
//The value of the local variable 'uint8list' isn't used.
//It is displayed as above. It is considered unused.
var uint8list; //←string color is gray.
var file;
var bytes;
Widget sumb=Container(width:100);
try{
uint8list = await VideoThumbnail.thumbnailFile(
video: tempurl,
thumbnailPath: (await getTemporaryDirectory()).path,
imageFormat: ImageFormat.WEBP,
maxHeight: 200,
// specify the height of the thumbnail, let the width auto-scaled to keep the source aspect ratio
quality: 75,
);
}catch(e){
}
uint8list=""; //←← Described as a trial. Even with this, the declaration part remains gray.
我正在尝试从上传到 firebase 中 cloud_storage 的视频文件创建缩略图,但在途中我遇到了不熟悉的行为。
我正在使用 VideoThumbnail 包中的 VideoThumbnail.thumbnailFile 方法。 该方法是异步方法,返回Future,但有时创建缩略图失败并出现错误,所以我正在尝试编写异常处理。
在上面的代码中,uint8list 是灰色的,并且出现了“变量未使用”的消息,但我认为即使考虑到范围,它也可以清楚地使用。
我认为可以从 try 块 {} 内部访问外部范围内的变量, 在飞镖朗。 我错了吗?
【问题讨论】:
标签: android-studio flutter dart