我正在尝试在Flutter中制作一个图像拾取器,在那里我可以从画廊中选择图像。
我不知道一些图像拾取器的内置代码或库。
发布于 2020-02-10 07:36:30
我知道我可能会晚一点,但你可以用这个图书馆。
它会返回图库和目前正在开发中的图库的图片,但应该可以在安卓上完美地工作,而对于iOS,它还没有完全实现。
如何使用它
要获取专辑,请执行以下操作:
List<PhoneAlbum> phoneAlbums = [];
final customImagePicker = CustomImagePicker();
Future<void> getGallery() async {
try {
await customImagePicker.getAlbums(callback: (msg) {
setState(() {
phoneAlbums = msg;
});
});
} on PlatformException {}
}电话相册具有以下属性
String id;
String name;
String coverUri;
int photosCount;要获取相册的照片:
List<PhonePhoto> images = [];
final customImagePicker = CustomImagePicker();
Future<void> getPhotosOfGallery(String albumID) async {
List<PhonePhoto> allImages = [];
try {
final cancelElement = await customImagePicker.getPhotosOfAlbum(albumID, callback: (msg) {
print('The message is $msg');
});
} on PlatformException {}
setState(() {
images = allImages;
});
}手机照片具有以下属性:
String id;
String albumName;
String photoUri;这有助于您以您喜欢的方式显示图像,并且很快就可以获取视频,以及分页(延迟加载),以提高性能
https://stackoverflow.com/questions/58663096
复制相似问题