ImageFile constructor

ImageFile({
  1. required String filePath,
  2. required Uint8List rawBytes,
  3. String? contentType,
  4. int? width,
  5. int? height,
})

Implementation

ImageFile({
  required this.filePath,
  required this.rawBytes,
  String? contentType,
  int? width,
  int? height,
})  : _contentType = contentType,
      _width = width,
      _height = height {
  if (width == null && height == null) {
    ImageSizeData? imageSizeData;
    try {
      imageSizeData = ImageSizeData.fromBytes(rawBytes);
    } catch (_) {}

    _width = imageSizeData?.width;
    _height = imageSizeData?.height;
  }

  if (contentType == null) {
    _contentType = mime.lookupMimeType(
      filePath,
      headerBytes: List.from(rawBytes),
    );
  }
}