首页 > 解决方案 > 未处理的异常:键入“列表”' 不是类型 '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}");
    
  }

}
                                                     
                                                                                   

标签: flutterflutter-video-player

解决方案


推荐阅读