check image for null safety

This commit is contained in:
tzw
2021-09-10 16:48:24 +06:30
parent 1bbff6e4cd
commit 3dde95f23f
5 changed files with 42 additions and 30 deletions

View File

@@ -8,17 +8,26 @@ class DisplayImageSource {
File? file;
DisplayImageSource({this.url, this.file});
ImageProvider? get imageProvider =>
file == null ? CachedNetworkImageProvider(url!) : FileImage(file!);
ImageProvider get imageProvider {
if (file == null) {
return CachedNetworkImageProvider(url!);
} else {
return FileImage(file!);
}
}
@override
bool operator ==(other) {
if (identical(this, other)) {
if (identical(this, other) && other is DisplayImageSource) {
return true;
}
return (other.file == this.file &&
return (other is DisplayImageSource &&
other.file == this.file &&
(other.file != null || this.file != null)) ||
(other.url == this.url && (other.url != null || this.url != null));
(other is DisplayImageSource &&
other.url == this.url &&
(other.url != null || this.url != null));
}
@override