有没有办法访问转换为 Uint8List 的视频文件路径

Is there any way to access the video file path that converted to Uint8List

在下面的flutter_material_pickers插件代码中,我想获取视频文件路径,但是showMaterialFilePicker函数返回的file变量是Uint8List类型。

 void onTap() {
    if (value == null) {
      showMaterialFilePicker(
        fileType: Filetype.video,
        onChanged: (file) => setState(() {
          didChange(file);
          if (widget.onChanged != null) widget.onChanged(file);
        }),
      );
    } else {
      _showUnattachDialog();
    }
  }

参考flutter_material_pickers的这个函数,代码为:

import 'dart:async';
import 'dart:io';
import 'dart:typed_data';

import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

/// Allows selection of a file.
Future<void> showMaterialFilePicker({
  BuildContext context,
  FileType fileType = FileType.image,
  String fileExtension,
  ValueChanged<Uint8List> onChanged,
}) async {
  try {
    File file = await FilePicker.getFile(type: fileType);
    var data = file.readAsBytesSync();
    if (onChanged != null && file != null) onChanged(data);
  } catch (error) {
    if (error.runtimeType is PlatformException) return; // user clicked twice
    if (error.runtimeType is NoSuchMethodError) return; // user canceled dialog
    throw error;
  }
}

不,没有从 Uint8List 读取路径的选项。这种类型只存储字节数据。您甚至可以通过比较来自不同位置的两个相同图像的 readAsBytes() 结果来测试它。

您可以使用 file_picker (this package is used in flutter_material_pickers as well) and get File as in Usage 部分,并且您可以从 File 访问路径。