1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65import 'package:equatable/equatable.dart';
import 'package:journey/entries/entries.dart';
import 'package:journey/models/uuid.dart';
import 'package:meta/meta.dart';
@immutable
class LatLng extends Equatable {
final double latitude;
final double longitude;
const LatLng(this.latitude, this.longitude);
static const UNKNOWN = LatLng(-1, -1);
@override
int get hashCode => latitude.hashCode ^ (longitude.hashCode * 1000);
@override
List<Object?> get props => [latitude, longitude];
}
@immutable
class Location extends Equatable {
final String city;
final String country;
final LatLng latLng;
const Location(this.city, this.country, this.latLng);
static const UNKNOWN = Location('', '', LatLng.UNKNOWN);
@override
List<Object?> get props => [city, country, latLng];
/// Returns a formal `city, country` string for displaying this location in a
/// human-readable format.
String formattedLocation() {
return '$city, $country';
}
}
@immutable
class Entry extends Equatable {
final String id;
final String title;
final String body;
final DateTime dateTime;
final Location location;
Entry(
{String? id,
required String title,
required String body,
DateTime? dateTime,
required Location location})
: id = id ?? Uuid().generateV4(),
title = title,
body = body,
dateTime = dateTime ?? DateTime.now(),
location = location;
@override
List<Object?> get props => [id, title, body, dateTime, location];
}