getImages static method

Future<List<Uint8List>> getImages()

Implementation

static Future<List<Uint8List>> getImages() async {
  FilePickerResult? result = await FilePicker.platform.pickFiles(
    type: FileType.image,
    allowMultiple: true,
    withData: true,
  );

  List<Uint8List> bytes = <Uint8List>[];

  if (kIsWeb) {
    bytes = result?.files.map((e) => e.bytes ?? Uint8List(0)).toList() ??
        <Uint8List>[];
  } else {
    await Future.forEach((result?.files ?? <PlatformFile>[]),
        (PlatformFile e) async {
      if (e.path != null) {
        File file = File(e.path!);
        Uint8List b = await file.readAsBytes();
        bytes.add(b);
      }
    });
  }

  return bytes;
}