NativeFile constructor

NativeFile({
  1. required String name,
  2. required int size,
  3. String? path,
  4. Uint8List? bytes,
  5. Stream<List<int>>? stream,
  6. MediaType? mime,
  7. Size? dimensions,
})

Implementation

NativeFile({
  required this.name,
  required this.size,
  this.path,
  Uint8List? bytes,
  Stream<List<int>>? stream,
  this.mime,
  Size? dimensions,
}) : bytes = Rx(bytes),
     dimensions = Rx(dimensions),
     _readStream = stream {
  // If possible, determine the `MIME` type right away.
  if (mime == null) {
    if (path != null) {
      var type = lookupMimeType(path!);
      if (type != null) {
        mime = MediaType.parse(type);
      }
    } else if (bytes != null) {
      var type = lookupMimeType(name, headerBytes: bytes);
      if (type != null) {
        mime = MediaType.parse(type);
      }
    }
  }

  if (bytes != null) {
    _determineDimension();
  }
}