Flutter图片视频文件选择插件

一,自己没事干写了个Flutter插件库。大家可以使用。不好用的地方可以指出。感谢asset_pickers的帮助。

二,依赖

dependencies:
flutterpluginwangfei: ^1.10.0

三,使用方法

1. ios下info.list下面添加权限
<key>NSPhotoLibraryAddUsageDescription</key>
    	<string>Do you allow this app to use albums?</string>
    	<key>NSPhotoLibraryUsageDescription</key>
    	<string>This app needs access to your photo album so you can use services like uploading pictures</string>
    	<key>NSCameraUsageDescription</key>
    	<string>This app requires your consent to use the camera features</string>
    	<key>NSAppTransportSecurity</key>
    	<dict>
    		<key>NSAllowsArbitraryLoads</key>
    		<true/>
    	</dict>
2.权限申请:运行之前必须动态申请权限。推荐使用permission_handler来获取动态权限。
///图片视频选声音选择如下
 imageBeanEntity = await PictureSelector()
        .openGallery(pictureMimeType: PictureMimeType.all)//可以选择的类型
        .maxSelectNum(maxSelectNum:10)//最大的选择数量
        .minSelectNum(minSelectNum:3)//最小的数量
        .enablePreviewAudio(enablePreviewAudio:true)//支持声音选择
        .compress(compress:true)//是否压缩
        .enableCrop(enablecrop:true)
        .imageSpanCount(imageSpancount:5)//一行的展示个数
        .isCamera(iscamera:true)//是否支持照相机
        .previewImage(previewImage:true)//是否支持图片
        .previewVideo(previewVideo:true)//是否支持视频
        .openClickSound(open:false)//点击是否伴随声音
        .getPhotoAlbumToNative();

///文件选择如下
await FilePickerBuilder.instance
        .setMaxCount(9)//最多选择文件数量
        .setActivityTitle("选择")///页面导航栏标题
        .addZipFileSupport([".zip", ".rar"])///zip支持的类型
        .getFileToNative();

四,演示如下

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

最后关注我的github
插件官方地址
插件github
个人免费教学视频

发布了47 篇原创文章 · 获赞 54 · 访问量 15万+

猜你喜欢

转载自blog.csdn.net/m0_37667770/article/details/105000456