Remove info-level lint issues: avoid_dynamic_calls, use_build_context_synchronously, avoid_print, non_constant_identifier_names

- Type dynamic map accesses properly (avoid_dynamic_calls in genericMap, globalFiresBottomStats)
- Capture context before async gaps (use_build_context_synchronously in genericMap, genericMapBottom, globalFiresBottomStats)
- Replace print() with debugPrint() (avoid_print in firesApi.dart)
- Rename fireMarker function and _LayerSelectorButton to camelCase
- Rename variable FireNotifications to fireNotifications
- Fix no_default_cases in switch statements (add missing subscriptionConfirm case)
- Make FireNotification fields final, remove @immutable from YourLocation (mutable)
- Make monitoredAreas field final in _ViewModel
- Update subscribeViaApi to use copyWith instead of direct field assignment
This commit is contained in:
vjrj 2026-03-11 16:53:48 +01:00
parent 82cf8fc7cc
commit 270d9a569e
12 changed files with 72 additions and 61 deletions

View file

@ -23,7 +23,7 @@ class FireNotification {
factory FireNotification.fromJson(Map<String, dynamic> json) =>
_$FireNotificationFromJson(json);
@JsonKey(toJson: objectIdToJson, fromJson: objectIdFromJson)
ObjectId id;
final ObjectId id;
final double lat;
final double lon;
final String description;

View file

@ -10,10 +10,10 @@ const String fireNotificationKey = 'fireNotifications';
Future<List<FireNotification>> loadFireNotifications() async {
return globals.prefs.then((SharedPreferences prefs) {
final List<String>? FireNotifications =
final List<String>? fireNotifications =
prefs.getStringList(fireNotificationKey);
final List<FireNotification> persistedList = <FireNotification>[];
for (final String notificationString in (FireNotifications ?? <String>[])) {
for (final String notificationString in (fireNotifications ?? <String>[])) {
final Map<String, dynamic> notificationMap =
json.decode(notificationString) as Map<String, dynamic>;
persistedList.add(FireNotification.fromJson(notificationMap));

View file

@ -133,7 +133,7 @@ class FiresApi {
final String url =
'${state.firesApiUrl}fires-in-full/${state.firesApiKey}/$lat/$lon/$distance';
if (globals.isDevelopment) {
print(url);
debugPrint(url);
}
try {
final Response<dynamic> response = await _dio.get(url);
@ -218,7 +218,7 @@ class FiresApi {
response.data as Map<String, dynamic>;
final Map<String, dynamic> dataData =
data['data'] as Map<String, dynamic>;
print(dataData['upsert']);
debugPrint(dataData['upsert'].toString());
}
return true;
} else {

View file

@ -6,7 +6,6 @@ import '../objectIdUtils.dart';
part 'yourLocation.g.dart';
@immutable
@JsonSerializable()
class YourLocation {
YourLocation(
@ -16,20 +15,19 @@ class YourLocation {
this.description = '',
this.distance = 10,
int? currentNumFires,
this.subscribed = false}) {
this.currentNumFires = currentNumFires ?? 0;
}
this.subscribed = false})
: currentNumFires = currentNumFires ?? 0;
factory YourLocation.fromJson(Map<String, dynamic> json) =>
_$YourLocationFromJson(json);
@JsonKey(toJson: objectIdToJson, fromJson: objectIdFromJson)
ObjectId id;
final ObjectId id;
final double lat;
final double lon;
String description;
bool subscribed;
int distance;
late int currentNumFires;
int currentNumFires;
static YourLocation get noLocation {
_noLocation ??= YourLocation(id: ObjectId(), lat: 0.0, lon: 0.0);