VPlatformFile.fromMap constructor

VPlatformFile.fromMap(
  1. Map<String, dynamic> map
)

Implementation

factory VPlatformFile.fromMap(Map<String, dynamic> map) {
  final filePath = map['filePath'] as String?;
  final bytes = map['bytes'] as List?;
  final url = map['url'] as String?;

  if (filePath == null && bytes == null && url == null) {
    throw ArgumentError(
        "PlatformFileSource.fromMap: at least filePath or bytes or url must not be null. Map: $map");
  }

  return VPlatformFile._(
    name: map['name'],
    fileLocalPath: filePath,
    baseUrl: url,
    bytes: bytes?.map((e) => int.parse(e.toString(),radix: 10)).toList(),
    mimeType: map['mimeType'],
    fileSize: map['fileSize'] ?? 0,
    fileHash: (map['fileHash'] as String?) ??
        basenameWithoutExtension(map['name'] as String).replaceAll(" ", "-"),
  );
}