ImageScanResult.fromPlatformData constructor

ImageScanResult.fromPlatformData(
  1. dynamic data
)

Creates an ImageScanResult from the raw platform channel data.

On Android, the data is a Map with 'images' key. On iOS, the data is a List of file paths.

Implementation

factory ImageScanResult.fromPlatformData(dynamic data) {
  if (data is Map) {
    final images = (data['images'] as List?)?.cast<String>() ?? [];
    return ImageScanResult(images: images);
  }
  if (data is List) {
    return ImageScanResult(images: data.cast<String>());
  }
  throw FormatException(
    'Unexpected image scan result type: ${data.runtimeType}',
  );
}