todos-contra-el-fuego-mobile/lib/models/yourLocation.dart
vjrj 8da3752193 Fix 23 additional lint issues to reduce from 129 to 106 issues
- Add const constructors to @immutable classes (5 issues: prefer_const_constructors_in_immutables)
- Fix nullable value casts in firesApi.dart (3 issues: cast_nullable_to_non_nullable)
- Remove redundant default argument values (2 issues: avoid_redundant_argument_values)
- Make YourLocation immutable with final fields (2 issues: avoid_equals_and_hash_code_on_mutable_classes)
- Update imports and fix formatting

Reduces lint issues from 129 to 106. APK builds successfully (146 MB).
2026-03-11 23:45:06 +01:00

88 lines
2.4 KiB
Dart

import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
import 'package:objectid/objectid.dart';
import '../objectIdUtils.dart';
part 'yourLocation.g.dart';
@immutable
@JsonSerializable()
class YourLocation {
const YourLocation(
{required this.id,
required this.lat,
required this.lon,
this.description = '',
this.distance = 10,
int? currentNumFires,
this.subscribed = false})
: currentNumFires = currentNumFires ?? 0;
factory YourLocation.fromJson(Map<String, dynamic> json) =>
_$YourLocationFromJson(json);
@JsonKey(toJson: objectIdToJson, fromJson: objectIdFromJson)
final ObjectId id;
final double lat;
final double lon;
final String description;
final bool subscribed;
final int distance;
final int currentNumFires;
static YourLocation get noLocation {
_noLocation ??= YourLocation(id: ObjectId(), lat: 0.0, lon: 0.0);
return _noLocation!;
}
static YourLocation? _noLocation;
static const int? withoutStats = null;
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}';
}
}