refactor: null safe MatrixFile
This commit is contained in:
parent
b455a54304
commit
01c3b4d0bc
|
|
@ -1,4 +1,3 @@
|
||||||
// @dart=2.9
|
|
||||||
/*
|
/*
|
||||||
* Famedly Matrix SDK
|
* Famedly Matrix SDK
|
||||||
* Copyright (C) 2020, 2021 Famedly GmbH
|
* Copyright (C) 2020, 2021 Famedly GmbH
|
||||||
|
|
@ -37,11 +36,11 @@ class MatrixFile {
|
||||||
return await encryptFile(bytes);
|
return await encryptFile(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixFile({this.bytes, this.name, this.mimeType}) {
|
MatrixFile({required this.bytes, required String name, String? mimeType})
|
||||||
mimeType ??=
|
: mimeType = mimeType ??
|
||||||
lookupMimeType(name, headerBytes: bytes) ?? 'application/octet-stream';
|
lookupMimeType(name, headerBytes: bytes) ??
|
||||||
name = name.split('/').last.toLowerCase();
|
'application/octet-stream',
|
||||||
}
|
name = name.split('/').last.toLowerCase() {}
|
||||||
|
|
||||||
int get size => bytes.length;
|
int get size => bytes.length;
|
||||||
|
|
||||||
|
|
@ -65,14 +64,14 @@ class MatrixFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
class MatrixImageFile extends MatrixFile {
|
class MatrixImageFile extends MatrixFile {
|
||||||
int width;
|
int? width;
|
||||||
int height;
|
int? height;
|
||||||
String blurhash;
|
String? blurhash;
|
||||||
|
|
||||||
MatrixImageFile(
|
MatrixImageFile(
|
||||||
{Uint8List bytes,
|
{required Uint8List bytes,
|
||||||
String name,
|
required String name,
|
||||||
String mimeType,
|
String? mimeType,
|
||||||
this.width,
|
this.width,
|
||||||
this.height,
|
this.height,
|
||||||
this.blurhash})
|
this.blurhash})
|
||||||
|
|
@ -89,14 +88,14 @@ class MatrixImageFile extends MatrixFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
class MatrixVideoFile extends MatrixFile {
|
class MatrixVideoFile extends MatrixFile {
|
||||||
int width;
|
int? width;
|
||||||
int height;
|
int? height;
|
||||||
int duration;
|
int? duration;
|
||||||
|
|
||||||
MatrixVideoFile(
|
MatrixVideoFile(
|
||||||
{Uint8List bytes,
|
{required Uint8List bytes,
|
||||||
String name,
|
required String name,
|
||||||
String mimeType,
|
String? mimeType,
|
||||||
this.width,
|
this.width,
|
||||||
this.height,
|
this.height,
|
||||||
this.duration})
|
this.duration})
|
||||||
|
|
@ -113,10 +112,13 @@ class MatrixVideoFile extends MatrixFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
class MatrixAudioFile extends MatrixFile {
|
class MatrixAudioFile extends MatrixFile {
|
||||||
int duration;
|
int? duration;
|
||||||
|
|
||||||
MatrixAudioFile(
|
MatrixAudioFile(
|
||||||
{Uint8List bytes, String name, String mimeType, this.duration})
|
{required Uint8List bytes,
|
||||||
|
required String name,
|
||||||
|
String? mimeType,
|
||||||
|
this.duration})
|
||||||
: super(bytes: bytes, name: name, mimeType: mimeType);
|
: super(bytes: bytes, name: name, mimeType: mimeType);
|
||||||
@override
|
@override
|
||||||
String get msgType => 'm.audio';
|
String get msgType => 'm.audio';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue