AdaptiveFile.fromBytes constructor

AdaptiveFile.fromBytes(
  1. Uint8List bytes, {
  2. required String name,
  3. String? mimeType,
  4. int? width,
  5. int? height,
  6. int? size,
  7. DateTime? lastModified,
})

Creates an AdaptiveFile from raw in-memory bytes.

Implementation

factory AdaptiveFile.fromBytes(
  Uint8List bytes, {
  required String name,
  String? mimeType,
  int? width,
  int? height,
  int? size,
  DateTime? lastModified,
}) {
  final inferredMime = mimeType ?? _inferMimeType(name);
  return AdaptiveFile(
    path: null,
    name: name,
    bytes: bytes,
    mimeType: inferredMime,
    width: width,
    height: height,
    size: size ?? bytes.lengthInBytes,
    lastModified: lastModified ?? DateTime.now(),
  );
}