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

@ -364,6 +364,7 @@ class GenericMapState extends State<GenericMap> {
switch (status) {
case FireMapStatus.view:
case FireMapStatus.unsubscribe:
case FireMapStatus.subscriptionConfirm:
return <Widget>[
IconButton(
icon: const Icon(Icons.edit),
@ -384,8 +385,6 @@ class GenericMapState extends State<GenericMap> {
'${view.mapState.fireNotification?.description ?? 'Fire'}. ${view.serverUrl}fire/${view.mapState.fireNotification?.sealed ?? ''}');
})
];
default:
return <Widget>[];
}
}
@ -409,10 +408,10 @@ class GenericMapState extends State<GenericMap> {
// print('false pos: ${coords}');
final LatLng loc = LatLng(
(coords[1] as num).toDouble(), (coords[0] as num).toDouble());
markers.add(FireMarker(loc, FireMarkType.falsePos, () {
markers.add(fireMarker(loc, FireMarkType.falsePos, () {
_showFalsePositiveDialog(loc);
}));
// if (calibrate) markers.add(FireMarker(loc, FireMarkType.pixel));
// if (calibrate) markers.add(fireMarker(loc, FireMarkType.pixel));
} catch (e, stackTrace) {
reportError(e, stackTrace);
}
@ -420,55 +419,62 @@ class GenericMapState extends State<GenericMap> {
for (final dynamic industry in industries) {
try {
// print(fire['geo']['coordinates']);
final List<dynamic> coords =
industry['geo']['coordinates'] as List<dynamic>;
final Map<String, dynamic> industryMap =
industry as Map<String, dynamic>;
final dynamic geoData = industryMap['geo'];
final Map<String, dynamic> geo = geoData as Map<String, dynamic>;
final List<dynamic> coords = geo['coordinates'] as List<dynamic>;
final LatLng loc = LatLng(
(coords[1] as num).toDouble(), (coords[0] as num).toDouble());
markers.add(FireMarker(loc, FireMarkType.industry, () {
markers.add(fireMarker(loc, FireMarkType.industry, () {
_showIndustryDialog(loc);
}));
// if (calibrate) markers.add(FireMarker(loc, FireMarkType.pixel));
// if (calibrate) markers.add(fireMarker(loc, FireMarkType.pixel));
} catch (e, stackTrace) {
reportError(e, stackTrace);
}
}
for (final dynamic fire in fires) {
try {
final LatLng loc = LatLng(
(fire['lat'] as num).toDouble(), (fire['lon'] as num).toDouble());
markers.add(FireMarker(loc, FireMarkType.fire, () {
onFirePressed(loc, DateTime.parse(fire['when'].toString()),
fire['type'] as String);
final Map<String, dynamic> fireMap = fire as Map<String, dynamic>;
final dynamic lat = fireMap['lat'];
final dynamic lon = fireMap['lon'];
final dynamic when = fireMap['when'];
final dynamic type = fireMap['type'];
final LatLng loc =
LatLng((lat as num).toDouble(), (lon as num).toDouble());
markers.add(fireMarker(loc, FireMarkType.fire, () {
onFirePressed(loc, DateTime.parse(when.toString()), type as String);
}));
markers.add(FireMarker(loc, FireMarkType.pixel));
markers.add(fireMarker(loc, FireMarkType.pixel));
} catch (e, stackTrace) {
reportError(e, stackTrace);
}
}
markers.add(
FireMarker(pos, isNotif ? FireMarkType.fire : FireMarkType.position));
// if (calibrate) markers.add(FireMarker(pos, FireMarkType.pixel));
fireMarker(pos, isNotif ? FireMarkType.fire : FireMarkType.position));
// if (calibrate) markers.add(fireMarker(pos, FireMarkType.pixel));
return markers;
}
void _showFireDialog(LatLng pos, DateTime date, String type) {
final String when = Moment.fromDate(date).fromNow(context);
final S strings = S.of(context);
final String by =
type == 'vecinal' ? strings.byOurUsers : strings.byNASAsatellites;
getReverseLocation(lat: pos.latitude, lon: pos.longitude)
.then((String reverseLoc) {
final String by = type == 'vecinal'
? S.of(context).byOurUsers
: S.of(context).byNASAsatellites;
final String fireDesc =
S.of(context).additionalInfoAboutFire(reverseLoc, when, by);
strings.additionalInfoAboutFire(reverseLoc, when, by);
showDialog<bool>(
context: _scaffoldKey.currentContext!,
builder: (_) => AlertDialog(
content: Text(fireDesc),
actions: <Widget>[
TextButton(
child: Text(S.of(context).CLOSE),
child: Text(strings.CLOSE),
onPressed: () {
Navigator.pop(context);
Navigator.pop(_scaffoldKey.currentContext!);
},
),
],
@ -477,21 +483,22 @@ class GenericMapState extends State<GenericMap> {
}
void _showIndustryDialog(LatLng pos) {
final S strings = S.of(context);
getReverseLocation(lat: pos.latitude, lon: pos.longitude)
.then((String reverseLoc) {
final String industryDesc = '${S.of(context).itSeemsAIndustry}\n\n'
final String industryDesc = '${strings.itSeemsAIndustry}\n\n'
'Type: Industry\n'
'Location: $reverseLoc';
showDialog<bool>(
context: _scaffoldKey.currentContext!,
builder: (_) => AlertDialog(
title: Text(S.of(context).notAWildfire),
title: Text(strings.notAWildfire),
content: Text(industryDesc),
actions: <Widget>[
TextButton(
child: Text(S.of(context).CLOSE),
child: Text(strings.CLOSE),
onPressed: () {
Navigator.pop(context);
Navigator.pop(_scaffoldKey.currentContext!);
},
),
],
@ -500,21 +507,22 @@ class GenericMapState extends State<GenericMap> {
}
void _showFalsePositiveDialog(LatLng pos) {
final S strings = S.of(context);
getReverseLocation(lat: pos.latitude, lon: pos.longitude)
.then((String reverseLoc) {
final String falseDesc = '${S.of(context).itSeemsNotAtForesFire}\n\n'
final String falseDesc = '${strings.itSeemsNotAtForesFire}\n\n'
'Type: False Positive\n'
'Location: $reverseLoc';
showDialog<bool>(
context: _scaffoldKey.currentContext!,
builder: (_) => AlertDialog(
title: Text(S.of(context).notAWildfire),
title: Text(strings.notAWildfire),
content: Text(falseDesc),
actions: <Widget>[
TextButton(
child: Text(S.of(context).CLOSE),
child: Text(strings.CLOSE),
onPressed: () {
Navigator.pop(context);
Navigator.pop(_scaffoldKey.currentContext!);
},
),
],