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

Flutter中使用FFmpeg时无法找到ReturnCode的问题排查

编译错误“Unable to find ReturnCode”的解决办法

这段Dart代码编译报错的核心原因是ReturnCode类未被导入。ReturnCode是ffmpeg_kit_flutter库中用于判断命令执行状态的工具类,它并不包含在当前导入的ffmpeg_kit.dart文件中。

解决步骤

在现有导入语句下方,补充导入ReturnCode对应的文件:

import 'package:ffmpeg_kit_flutter/return_code.dart';

修正后的完整代码

import 'package:ffmpeg_kit_flutter/ffmpeg_kit.dart';
import 'package:ffmpeg_kit_flutter/return_code.dart'; // 新增导入

class Video {

  /// Executes the command
  void execute(String command) async {
    FFmpegKit.execute(command).then((session) async {
      final returnCode = await session.getReturnCode();

      if (ReturnCode.isSuccess(returnCode)) {
        // SUCCESS

      } else if (ReturnCode.isCancel(returnCode)) {
        // CANCEL

      } else {
        // ERROR

      }
    });
  }
}

补充说明

ReturnCode类封装了命令执行的成功、取消、错误等状态判断逻辑,属于库中独立的模块,必须显式导入对应的return_code.dart文件才能正常使用。

内容的提问来源于stack exchange,提问作者Stéphane de Luca

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.10 14:50:45