platform/packages/client/test/shared.dart

33 lines
742 B
Dart
Raw Normal View History

2021-05-15 06:53:03 +00:00
import 'package:angel3_model/angel3_model.dart';
2023-06-10 04:10:21 +00:00
import 'package:quiver/core.dart';
2016-06-24 21:06:57 +00:00
2017-02-22 22:20:30 +00:00
class Postcard extends Model {
2021-04-10 13:22:20 +00:00
String? location;
String? message;
2016-06-24 21:06:57 +00:00
2021-04-10 13:22:20 +00:00
Postcard({String? id, this.location, this.message}) {
2017-02-22 22:20:30 +00:00
this.id = id;
}
2021-04-10 13:22:20 +00:00
factory Postcard.fromJson(Map data) => Postcard(
2018-08-26 22:41:01 +00:00
id: data['id'].toString(),
location: data['location'].toString(),
message: data['message'].toString());
2016-06-24 21:06:57 +00:00
@override
bool operator ==(other) {
2022-08-27 07:49:21 +00:00
if (other is! Postcard) return false;
2016-06-24 21:06:57 +00:00
2016-12-10 17:28:24 +00:00
return id == other.id &&
location == other.location &&
2016-06-24 21:06:57 +00:00
message == other.message;
}
2016-12-10 17:28:24 +00:00
Map toJson() {
return {'id': id, 'location': location, 'message': message};
}
2023-06-10 04:10:21 +00:00
@override
int get hashCode => hash2(id, location);
2016-12-10 17:28:24 +00:00
}