如何从一处挑选颤振中的图像或视频?

Oma*_*eem 4 android ios dart flutter

我正在使用 image_picker 插件来选取图像和视频,但在插件示例中,您必须选择要从库中选取图像或视频。那么是否有另一种方法可以将两者一起显示在一个地方?

 final ImagePicker _picker = ImagePicker();
// Pick an image
final XFile? image = await _picker.pickImage(source: 
ImageSource.gallery);

// Pick a video
final XFile? image = await _picker.pickVideo(source: 
ImageSource.gallery);
Run Code Online (Sandbox Code Playgroud)

小智 5

您依赖于plugin您使用的及其功能。如果它不能提供您所需要的,您需要开发自己的plugin或尝试使用另一种。如果这plugin对您来说是可以改变的,请查看以下解决方案:

1- wechat_assets_picker

final List<AssetEntity>? assets = await AssetPicker.pickAssets(
  context,
  maxAssets: 2,
  requestType: RequestType.all,
  pickerTheme: appTheme,
  textDelegate: EnglishTextDelegate(),
);
Run Code Online (Sandbox Code Playgroud)

它提供了不同的,RequestType如,,,,和。audiovideocommonimageall

2-照片管理器

final assetPathEntityList =
  await PhotoManager.getAssetPathList(type: RequestType.all);
Run Code Online (Sandbox Code Playgroud)

该插件还提供了不同的功能RequestType,例如audiovideocommonimageall等。不同之处在于没有UI小部件。因此,你需要发展你的UI并与之联系plugin

如果您还有其他问题,请随时在评论中写下。