- introPage.dart: Convert fireItems to proper static function closure - mainDrawer.dart: Convert unreadCount int to String for Text widget
87 lines
2.4 KiB
Dart
87 lines
2.4 KiB
Dart
import 'package:json_annotation/json_annotation.dart';
|
|
import 'package:objectid/objectid.dart';
|
|
|
|
import '../objectIdUtils.dart';
|
|
|
|
part 'yourLocation.g.dart';
|
|
|
|
@JsonSerializable(nullable: false)
|
|
class YourLocation {
|
|
|
|
YourLocation(
|
|
{required this.id,
|
|
required this.lat,
|
|
required this.lon,
|
|
this.description = '',
|
|
this.distance = 10,
|
|
int? currentNumFires,
|
|
this.subscribed = false}) {
|
|
this.currentNumFires = currentNumFires ?? 0;
|
|
}
|
|
|
|
factory YourLocation.fromJson(Map<String, dynamic> json) =>
|
|
_$YourLocationFromJson(json);
|
|
@JsonKey(toJson: objectIdToJson, fromJson: objectIdFromJson)
|
|
ObjectId id;
|
|
final double lat;
|
|
final double lon;
|
|
String description;
|
|
bool subscribed;
|
|
int distance;
|
|
late int currentNumFires;
|
|
|
|
static late final YourLocation noLocation;
|
|
static const int? withoutStats = null;
|
|
|
|
static void _initNoLocation() {
|
|
noLocation = YourLocation(
|
|
id: ObjectId(), lat: 0.0, lon: 0.0);
|
|
}
|
|
Map<String, dynamic> toJson() => _$YourLocationToJson(this);
|
|
|
|
YourLocation copyWith(
|
|
{ObjectId? id,
|
|
double? lat,
|
|
double? lon,
|
|
String? description,
|
|
int? distance,
|
|
int? currentNumFires,
|
|
bool? subscribed}) {
|
|
return YourLocation(
|
|
id: id ?? this.id,
|
|
lat: lat ?? this.lat,
|
|
lon: lon ?? this.lon,
|
|
description: description ?? this.description,
|
|
distance: distance ?? this.distance,
|
|
currentNumFires: currentNumFires ?? this.currentNumFires,
|
|
subscribed: subscribed ?? this.subscribed);
|
|
}
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is YourLocation &&
|
|
runtimeType == other.runtimeType &&
|
|
id == other.id &&
|
|
lat == other.lat &&
|
|
lon == other.lon &&
|
|
description == other.description &&
|
|
subscribed == other.subscribed &&
|
|
currentNumFires == other.currentNumFires &&
|
|
distance == other.distance;
|
|
|
|
@override
|
|
int get hashCode =>
|
|
id.hashCode ^
|
|
lat.hashCode ^
|
|
lon.hashCode ^
|
|
description.hashCode ^
|
|
subscribed.hashCode ^
|
|
currentNumFires.hashCode ^
|
|
distance.hashCode;
|
|
|
|
@override
|
|
String toString() {
|
|
return 'YourLocation {id: $id, lat: $lat, lon: $lon, description: $description, subscribed: $subscribed, distance: $distance, currentNumFires: $currentNumFires}';
|
|
}
|
|
}
|