single static method

Future<AssetEntity?> single(
  1. BuildContext context
)

选择单个图片

Implementation

static Future<AssetEntity?> single(BuildContext context) async {
  int gridCount = 4;
  final List<AssetEntity>? assets = await AssetPicker.pickAssets(
    context,
    maxAssets: 1,
    //最多选择的图片数量
    pageSize: 80 * gridCount,
    //分页加载时每页加载的资源数量。必须为网格数的倍数。 设置为null可以取消分页。
    pathThumbSize: 200,
    //选择器的缩略图大小
    gridCount: gridCount,
    //选择器网格数量
    requestType: RequestType.image,
    //选择器选择资源的类型
    themeColor: HColors.app_accent_5A46BE,
  );

  if (assets?.length == 1) {
    AssetEntity asset = assets![0];
    return asset;
  }
  return null;
}