- Fix AppState: remove removed connectivity package, fix imports (latlong2), make nullable fields optional - Fix User model: use const empty strings in const constructor instead of null - Fix model builders: add required ObjectId parameters to YourLocation and FireNotification - Implement Comparable instead of extending it for BasicLocation - Fix nullable callback handling in appActions and middleware (Completer<Null>?) - Add null checks for BuildContext in dialogs (fireAlert, homePage, etc.) - Fix nullable scaffold state access using ?. operator (activeFires, fireNotificationList) - Handle nullable FireNotification and YourLocation in genericMapBottom - Fix list type casting for widgets that can be null (<Widget?> with filtering) - Add ObjectId imports where needed for model creation - Fix Key? nullable parameter in introPage - Add required parameters to markdownPage and slider constructors - Remove connectivity-related code and imports (package removed) - Handle nullable Completer in fetchDataMiddleware All 104 errors resolved. 0 errors, 61 warnings/info remaining.
80 lines
2.3 KiB
Dart
80 lines
2.3 KiB
Dart
import 'package:fires_flutter/objectIdUtils.dart';
|
|
import 'package:json_annotation/json_annotation.dart';
|
|
import 'package:objectid/objectid.dart';
|
|
|
|
part 'yourLocation.g.dart';
|
|
|
|
@JsonSerializable(nullable: false)
|
|
class YourLocation {
|
|
@JsonKey(toJson: objectIdToJson, fromJson: objectIdFromJson)
|
|
ObjectId id;
|
|
final double lat;
|
|
final double lon;
|
|
String description;
|
|
bool subscribed;
|
|
int distance;
|
|
late int currentNumFires;
|
|
|
|
factory YourLocation.fromJson(Map<String, dynamic> json) =>
|
|
_$YourLocationFromJson(json);
|
|
|
|
static late final YourLocation noLocation;
|
|
static const int? withoutStats = null;
|
|
|
|
static void _initNoLocation() {
|
|
noLocation = new YourLocation(
|
|
id: ObjectId(), lat: 0.0, lon: 0.0, description: '', subscribed: false);
|
|
}
|
|
|
|
YourLocation(
|
|
{required this.id,
|
|
required this.lat,
|
|
required this.lon,
|
|
this.description = '',
|
|
this.distance = 10,
|
|
int? currentNumFires,
|
|
this.subscribed = false}) {
|
|
this.currentNumFires = currentNumFires ?? 0;
|
|
}
|
|
Map<String, dynamic> toJson() => _$YourLocationToJson(this);
|
|
|
|
YourLocation copyWith(
|
|
{id, lat, lon, description, distance, currentNumFires, subscribed}) {
|
|
return new 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}';
|
|
}
|
|
}
|