first commit
This commit is contained in:
68
lib/flutterlib/uploaded_file.dart
Normal file
68
lib/flutterlib/uploaded_file.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
|
||||
class FFUploadedFile {
|
||||
const FFUploadedFile({
|
||||
this.name,
|
||||
this.bytes,
|
||||
this.height,
|
||||
this.width,
|
||||
this.blurHash,
|
||||
});
|
||||
|
||||
final String? name;
|
||||
final Uint8List? bytes;
|
||||
final double? height;
|
||||
final double? width;
|
||||
final String? blurHash;
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'FFUploadedFile(name: $name, bytes: ${bytes?.length ?? 0}, height: $height, width: $width, blurHash: $blurHash,)';
|
||||
|
||||
String serialize() => jsonEncode(
|
||||
{
|
||||
'name': name,
|
||||
'bytes': bytes,
|
||||
'height': height,
|
||||
'width': width,
|
||||
'blurHash': blurHash,
|
||||
},
|
||||
);
|
||||
|
||||
static FFUploadedFile deserialize(String val) {
|
||||
final serializedData = jsonDecode(val) as Map<String, dynamic>;
|
||||
final data = {
|
||||
'name': serializedData['name'] ?? '',
|
||||
'bytes': serializedData['bytes'] ?? Uint8List.fromList([]),
|
||||
'height': serializedData['height'],
|
||||
'width': serializedData['width'],
|
||||
'blurHash': serializedData['blurHash'],
|
||||
};
|
||||
return FFUploadedFile(
|
||||
name: data['name'] as String,
|
||||
bytes: Uint8List.fromList(data['bytes'].cast<int>().toList()),
|
||||
height: data['height'] as double?,
|
||||
width: data['width'] as double?,
|
||||
blurHash: data['blurHash'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
name,
|
||||
bytes,
|
||||
height,
|
||||
width,
|
||||
blurHash,
|
||||
);
|
||||
|
||||
@override
|
||||
bool operator ==(other) =>
|
||||
other is FFUploadedFile &&
|
||||
name == other.name &&
|
||||
bytes == other.bytes &&
|
||||
height == other.height &&
|
||||
width == other.width &&
|
||||
blurHash == other.blurHash;
|
||||
}
|
||||
Reference in New Issue
Block a user