You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Flutter Pod Player播放视频时出现类型转换异常

使用pod_player播放Vimeo视频时遇到类型转换异常

我在使用pod_player包播放Vimeo视频时,触发了以下异常:

===== VIMEO API ERROR: type 'Null' is not a subtype of type 'List<dynamic>' in type cast ==========
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'List<dynamic>' in type cast
#0      PodPlayerController._checkAndWaitTillInitialized (package:pod_player/src/controllers/pod_player_controller.dart:76:9)
#1      PodPlayerController._checkAndWaitTillInitialized[(package:pod_player/src/controllers/pod_player_controller.dart:82:11)
<asynchronous suspension>
#2      PodPlayerController._checkAndWaitTillInitialized (package:pod_player/src/controllers/pod_player_controller.dart:82:5)
<asynchronous suspension>
#3      PodPlayerController.initialise (package:pod_player/src/controllers/pod_player_controller.dart:61:5)

错误界面:
错误界面

已尝试降级包版本,但问题仍未解决。


可能的解决方向

  • 排查视频权限与API返回
    确认目标Vimeo视频为公开可访问状态,且已开启Embed权限。私有或权限配置错误的视频可能导致API返回不完整数据。可以直接请求Vimeo的oEmbed接口(如https://vimeo.com/api/oembed.json?url=你的视频链接),检查返回数据中是否存在预期的列表字段,是否有Null值返回。

  • 修改包源码适配Null安全
    定位到pod_player包中PodPlayerController.dart第76行,此处存在将Null强制转为List的操作。可修改为安全处理逻辑:

    // 原代码示例
    final List<dynamic> data = response.data['target_key'] as List<dynamic>;
    // 修改后
    final List<dynamic>? data = response.data['target_key'] as List<dynamic>?;
    if (data == null) {
      throw Exception('Vimeo API返回数据缺失关键列表字段');
      // 或使用默认空列表:final List<dynamic> safeData = data ?? [];
    }
    

    修改后需在本地依赖中替换包源码,或向官方仓库提交修复PR。

  • 替换播放实现方式
    如果pod_player的Vimeo适配问题无法快速解决,可考虑直接用WebView加载Vimeo的Embed代码,或集成Vimeo官方提供的播放方案。

内容的提问来源于stack exchange,提问作者user3288482

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 23:31:04