flutter - 未处理的异常:键入“列表”' 不是类型 'String?' 的子类型 在类型转换中
问题描述
我收到错误未处理的异常:类型“列表”不是“字符串”类型的子类型?仅在 IOS 中,而不是在每个视频中。其他一些视频在没有任何错误的情况下被选中。在 android 中它可以正常工作,没有任何错误。会是什么呢?请帮忙..
Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'String?' in type cast
#0 MethodChannel._invokeMethod
(package:flutter/src/services/platform_channel.dart:158:41)
<asynchronous suspension>
#1 MethodChannelImagePicker.getVideo(package:image_picker_platform_interface/src/method_channel/method_. channel_image_picker.dart:220:26)
<asynchronous suspension>
#2 _AddVideo2.pickVideo (package:flutterapp/media/addVideo2.dart:29:21)
错误将我带到了这个:-
final video = (error)await ImagePicker()
.pickVideo(source: source, maxDuration:
完整代码:-
class AddVideo2 extends StatefulWidget {
final String videoFrom;
const AddVideo2({Key key, @required this.videoFrom}) : super(key: key);
@override
_AddVideo2 createState() => _AddVideo2();
}
class _AddVideo2 extends State<AddVideo2> {
pickVideo(ImageSource source) async {
//Navigator.pop(context);
if (storagePermission) {
final video = await ImagePicker()
.pickVideo(source: source, maxDuration:
Duration(seconds: 60));
if (video == null) {
Fluttertoast.showToast(
msg: "No Video Selected!!".tr(),
);
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ConfirmVideo(
videofile: File(video.path),
imageSource: source,
videoFrom: widget.videoFrom,
)));
}
}
}
@override
void initState() {
super.initState();
print("Video From: ${widget.videoFrom}");
}
}
解决方案
推荐阅读
- api - 我如何返回未来
在带有 Provider 的 ListView 中? - terraform - for_each 中带有动态块的 Terraform 错误
- python-3.x - 如何使按钮中功能的旧消息消失并在功能中出现新消息
- r - R:html_nodes 在站点上复制内容
- caffe - 用于图像分类的最简单的 caffe 网络
- flutter - 除了使用颤振的标题之外的搜索按钮?
- android - Facebook Android 应用程序如何安装 Facebook Messenger?
- c++ - std::variant 在 gcc 8 和 9 中需要默认构造函数,在 gcc 10/clang 中不需要
- java - 如何在 Java 应用程序中允许特殊字符,如破折号?
- c# - c# - 在列表中找到正确的元素