multiImageSelector function
Future<List<PFile?> >
multiImageSelector(
- BuildContext context, {
- int? maxSelections = 1,
- MediaContentType<
Object> ? mediaType, - dynamic extraOptions,
Implementation
@deprecated
Future<List<PFile?>> multiImageSelector(
BuildContext context, {
int? maxSelections = 1,
MediaContentType? mediaType,
dynamic extraOptions,
}) async {
final media = await MultiImagePicker.pickImages(
maxImages: maxSelections!,
enableCamera: true,
materialOptions: MaterialOptions(
textOnNothingSelected: "Nothing was selected!",
autoCloseOnSelectionLimit: true,
lightStatusBar: true,
),
cupertinoOptions: CupertinoOptions(
autoCloseOnSelectionLimit: true,
));
if (media.isNotEmpty != true) {
return [];
}
const double max = 1800.0;
final images = await Future.wait(media.map((asset) async {
final w = asset.originalWidth!;
final h = asset.originalHeight!;
double ratio, ww, hh;
if (asset.isLandscape) {
if (w > max) {
ratio = max / w;
} else {
ratio = 1;
}
} else {
if (h > max) {
ratio = max / h;
} else {
ratio = 1;
}
}
ww = ratio * w;
hh = ratio * h;
final image = await asset.getThumbByteData(ww.truncate(), hh.truncate());
await getTemporaryDirectory();
final buffer = image.buffer;
final bytes = buffer.asUint8List(image.offsetInBytes, image.lengthInBytes);
return PFile.of(bytes, name: asset.name, size: bytes.length);
}));
return images;
}