flutter version:

a289b5dee073fd56949bc204d7b3cc9e.png

version: 1.0.0+1

environment:

sdk: ">=2.1.0 <3.0.0"

photo: 0.4.5 + 1

code:

GestureDetector( child: Text('从相册选择'), onTap: () async { var assetPathList = await PhotoManager.getImageAsset(); _pickAsset(PickType.onlyImage, pathList: assetPathList); }, ),

`

void _pickAsset(PickType type, {List pathList}) async {

Navigator.of(context).pop();

List imgList = await PhotoPicker.pickAsset(

// BuildContext required

context: context,

/// The following are optional parameters.

themeColor: Colors.black,

// the title color and bottom color

textColor: Colors.white,

// text color

padding: 1.0,

// item padding

dividerColor: Colors.grey,

// divider color

disableColor: Colors.grey.shade300,

// the check box disable color

itemRadio: 0.88,

// the content item radio

maxSelected: 9 - _imgControList.length,

// max picker image count

// provider: I18nProvider.english,

provider: I18nProvider.chinese,

// i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()

rowCount: 3,

// item row count

thumbSize: 150,

// preview thumb size , default is 64

sortDelegate: SortDelegate.common,

// default is common ,or you make custom delegate to sort your gallery

checkBoxBuilderDelegate: DefaultCheckBoxBuilderDelegate(

activeColor: Colors.white,

unselectedColor: Colors.white,

// checkColor: Colors.green,

),

// default is DefaultCheckBoxBuilderDelegate ,or you make custom delegate to create checkbox

// if you want to build custom loading widget,extends LoadingDelegate, [see example/lib/main.dart]

badgeDelegate: const DurationBadgeDelegate(),

// badgeDelegate to show badge widget

pickType: type,

photoPathList: pathList,

);

if (imgList == null) {

currentSelected = "not select item";

} else {

List r = []; // img 真实路径数组

for (var e in imgList) {

setState(() {

_showLoadingTag = true;

});

var file = await e.file;

_uploadImg(EditableActivityItem(thumbnail: file.absolute.path));

}

}

setState(() {});

}

`

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐