photo_album_manager這是可以快速獲取相冊(cè)資源的插件枫慷,支持安卓和iOS;支持升序降序獲忍樗住神帅;支持圖片視頻分開(kāi)獲取找御;支持自定義數(shù)量獲壬芴睢栖疑;iOS端支持iCloud云端資源下載及下載進(jìn)度回調(diào)等;
code
/*獲取相冊(cè)資源(降序) maxCount 為null 獲取全部資源*/
static Future<List<AlbumModelEntity>> getDescAlbum({int maxCount}) async {
List list = await _channel.invokeMethod('getDescAlbum', maxCount);
List<AlbumModelEntity> album = List();
list.forEach((item) => album.add(AlbumModelEntity.fromJson(item)));
return album;
}
/*獲取相冊(cè)資源(升序) maxCount 為null 獲取全部資源*/
static Future<List<AlbumModelEntity>> getAscAlbum({int maxCount}) async {
List list = await _channel.invokeMethod('getAscAlbum', maxCount);
List<AlbumModelEntity> album = List();
list.forEach((item) => album.add(AlbumModelEntity.fromJson(item)));
return album;
}
/*獲取相冊(cè)圖片資源(升序) maxCount 為null 獲取全部資源*/
static Future<List<AlbumModelEntity>> getAscAlbumImg({int maxCount}) async {
List list = await _channel.invokeMethod('getAscAlbumImg', maxCount);
List<AlbumModelEntity> album = List();
list.forEach((item) => album.add(AlbumModelEntity.fromJson(item)));
return album;
}
/*獲取相冊(cè)視頻資源(升序) maxCount 為null 獲取全部資源*/
static Future<List<AlbumModelEntity>> getAscAlbumVideo({int maxCount}) async {
List list = await _channel.invokeMethod('getAscAlbumVideo', maxCount);
List<AlbumModelEntity> album = List();
list.forEach((item) => album.add(AlbumModelEntity.fromJson(item)));
return album;
}
/*獲取相冊(cè)圖片資源(降序) maxCount 為null 獲取全部資源*/
static Future<List<AlbumModelEntity>> getDescAlbumImg({int maxCount}) async {
List list = await _channel.invokeMethod('getDescAlbumImg', maxCount);
List<AlbumModelEntity> album = List();
list.forEach((item) => album.add(AlbumModelEntity.fromJson(item)));
return album;
}
/*獲取相冊(cè)視頻資源(降序) maxCount 為null 獲取全部資源*/
static Future<List<AlbumModelEntity>> getDescAlbumVideo(
{int maxCount}) async {
List list = await _channel.invokeMethod('getDescAlbumVideo', maxCount);
List<AlbumModelEntity> album = List();
list.forEach((item) => album.add(AlbumModelEntity.fromJson(item)));
return album;
}
/*通過(guò)唯一標(biāo)識(shí)localIdentifier 獲取資源(原圖、原視頻)*/
static Future<AlbumModelEntity> getOriginalImg(String localIdentifier,
{void onProgress(double progress), void onError(String error)}) async {
if (Platform.isIOS) {
//監(jiān)聽(tīng)加載進(jìn)度
_eventChannel.receiveBroadcastStream().listen((Object object) {
if (object is double) {
onProgress(object);
} else {
onError(object);
}
});
List list =
await _channel.invokeMethod('getOriginalResource', localIdentifier);
if (list == null && list.length == 0) {
onError("加載失敗萝快,請(qǐng)重試");
return null;
}
AlbumModelEntity model = AlbumModelEntity.fromJson(list.first);
return model;
} else {
List list =
await _channel.invokeMethod('getOriginalResource', localIdentifier);
List<AlbumModelEntity> album = List();
list.forEach((item) => album.add(AlbumModelEntity.fromJson(item)));
return album.first;
}
}
install
dependencies:
photo_album_manager: ^1.0.4
import
import 'package:album_manager/photo_album_manager.dart';
use
List<AlbumModelEntity> photos = await PhotoAlbumManager.getDescAlbumImg(maxCount: 100);
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者