2020-09-17 06:02:48 +06:30
|
|
|
import 'dart:io';
|
|
|
|
|
|
2020-09-18 21:33:41 +06:30
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
2020-09-17 06:02:48 +06:30
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
|
|
|
|
|
|
class DisplayImageSource {
|
2021-09-10 14:25:37 +06:30
|
|
|
String? url;
|
|
|
|
|
File? file;
|
2020-09-17 06:02:48 +06:30
|
|
|
DisplayImageSource({this.url, this.file});
|
|
|
|
|
|
2021-09-10 16:48:24 +06:30
|
|
|
ImageProvider get imageProvider {
|
|
|
|
|
if (file == null) {
|
|
|
|
|
return CachedNetworkImageProvider(url!);
|
|
|
|
|
} else {
|
|
|
|
|
return FileImage(file!);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-17 06:02:48 +06:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
bool operator ==(other) {
|
2021-09-10 16:48:24 +06:30
|
|
|
if (identical(this, other) && other is DisplayImageSource) {
|
2020-09-17 06:02:48 +06:30
|
|
|
return true;
|
|
|
|
|
}
|
2021-09-10 16:48:24 +06:30
|
|
|
|
|
|
|
|
return (other is DisplayImageSource &&
|
|
|
|
|
other.file == this.file &&
|
2020-09-17 06:02:48 +06:30
|
|
|
(other.file != null || this.file != null)) ||
|
2021-09-10 16:48:24 +06:30
|
|
|
(other is DisplayImageSource &&
|
|
|
|
|
other.url == this.url &&
|
|
|
|
|
(other.url != null || this.url != null));
|
2020-09-17 06:02:48 +06:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
int get hashCode {
|
|
|
|
|
int result = 17;
|
|
|
|
|
result = 37 * result + file.hashCode;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|