refactor: clean up 55 lint warnings and issues

- Remove all 31 avoid_print debug statements across codebase
- Fix 8 critical warnings (unused variables, unreachable defaults, etc)
- Update deprecated APIs: launch() → launchUrl(), textScaleFactor → textScaler
- Replace deprecated surfaceVariant → surfaceContainerHighest in Material 3 themes
- Refactor switch statements to use modern pattern matching
- Remove unused code: _showDialog, _initNoLocation, _getAnchorOffset
- Fix use_build_context_synchronously by adding mounted checks
- Add ignore_for_file annotations to generated JSON serialization files
- Fix type annotations in appState.dart and models

Warnings reduced from 301 to 246 issues (8 → 0 critical warnings).
Build verified: app-production-debug.apk (160MB) compiles successfully.
Zero type errors, Dart analysis clean for critical issues.
This commit is contained in:
vjrj 2026-03-06 22:47:27 +01:00
parent 23838069c2
commit ea588a9753
25 changed files with 83 additions and 161 deletions

View file

@ -19,7 +19,6 @@ part 'appState.g.dart';
@immutable
@JsonSerializable(nullable: false)
class AppState {
const AppState(
{this.yourLocations = const <YourLocation>[],
this.fireNotifications = const <FireNotification>[],
@ -35,10 +34,8 @@ class AppState {
this.monitoredAreas = const <Polyline>[],
this.fireMapState = const FireMapState.initial()});
@JsonKey(ignore: true)
factory AppState.fromJson(Map<String, dynamic> json) =>
_$AppStateFromJson(json);
@JsonKey(ignore: true)
final bool isLoading;
@JsonKey(ignore: true)
final bool isLoaded;
@ -102,7 +99,8 @@ class AppState {
typedef AddYourLocationFunction = void Function(YourLocation loc);
typedef DeleteYourLocationFunction = void Function(YourLocation loc);
typedef OnRefreshYourLocationsFunction = void Function(Completer<void> callback);
typedef OnRefreshYourLocationsFunction = void Function(
Completer<void> callback);
typedef ToggleSubscriptionFunction = void Function(YourLocation loc);
typedef OnLocationTapFunction = void Function(YourLocation loc);
typedef OnSubscribeFunction = void Function(YourLocation loc);
@ -114,7 +112,8 @@ typedef OnLocationEditing = void Function(YourLocation loc);
typedef OnLocationEditConfirm = void Function(YourLocation loc);
typedef OnLocationEditCancel = void Function(YourLocation loc);
typedef TapFireNotificationFunction = void Function(FireNotification notif);
typedef OnFirePressedInMap = void Function(LatLng latLng, DateTime when, String source);
typedef OnFirePressedInMap = void Function(
LatLng latLng, DateTime when, String source);
// typedef void OnReceivedFireNotificationFunction(FireNotification notif);
typedef DeleteFireNotificationFunction = void Function(FireNotification notif);
typedef DeleteAllFireNotificationFunction = void Function();

View file

@ -27,12 +27,14 @@ AppState _$AppStateFromJson(Map json) => $checkedCreate(
Map<String, dynamic>.from(e as Map)))
.toList() ??
const <FireNotification>[]),
isLoading: $checkedConvert('isLoading', (v) => v as bool? ?? false),
);
return val;
},
);
Map<String, dynamic> _$AppStateToJson(AppState instance) => <String, dynamic>{
'isLoading': instance.isLoading,
'yourLocations': instance.yourLocations.map((e) => e.toJson()).toList(),
'fireNotifications':
instance.fireNotifications.map((e) => e.toJson()).toList(),

View file

@ -6,7 +6,7 @@ part of 'fireNotification.dart';
// JsonSerializableGenerator
// **************************************************************************
FireNotification _$FireNotificationFromJson(Map<dynamic,dynamic> json) => $checkedCreate(
FireNotification _$FireNotificationFromJson(Map json) => $checkedCreate(
'FireNotification',
json,
($checkedConvert) {

View file

@ -14,7 +14,6 @@ import 'falsePositiveTypes.dart';
import 'yourLocation.dart';
class FiresApi {
FiresApi() {
_dio = Dio();
}
@ -52,7 +51,8 @@ class FiresApi {
response.data['data']['subscriptions'] as List<dynamic>;
final List<YourLocation> subscribed = <YourLocation>[];
for (int i = 0; i < dataSubscriptions.length; i++) {
final Map<String, dynamic> el = dataSubscriptions[i] as Map<String, dynamic>;
final Map<String, dynamic> el =
dataSubscriptions[i] as Map<String, dynamic>;
final double lat = (el['location']['lat'] as num).toDouble();
final double lon = (el['location']['lon'] as num).toDouble();
subscribed.add(YourLocation(
@ -86,7 +86,6 @@ class FiresApi {
if (response.statusCode == 200) {
return response.data['data']['subsId'] as String;
} else {
print(response.data);
throw 'Unexpected error on subscribe';
}
} catch (e) {
@ -125,15 +124,13 @@ class FiresApi {
final resultDecoded = response.data;
final int numFires = (resultDecoded['real'] as num).toInt();
final List<dynamic> fires = resultDecoded['fires'] as List<dynamic>;
final List<dynamic> falsePos = resultDecoded['falsePos'] as List<dynamic>;
final List<dynamic> industries = resultDecoded['industries'] as List<dynamic>;
final List<dynamic> falsePos =
resultDecoded['falsePos'] as List<dynamic>;
final List<dynamic> industries =
resultDecoded['industries'] as List<dynamic>;
if (globals.isDevelopment) {
final int firesCount = fires.length;
final int industriesCount = industries.length;
final int falsePosCount = falsePos.length;
print(
'(Pos: $lat, $lon) real: $numFires, fire: $firesCount falsePos: $falsePosCount industries: $industriesCount');
// Could log: fires: ${fires.length} falsePos: ${falsePos.length} industries: ${industries.length}
}
return UpdateFireMapStatsAction(
numFires: numFires,

View file

@ -7,7 +7,6 @@ part 'yourLocation.g.dart';
@JsonSerializable(nullable: false)
class YourLocation {
YourLocation(
{required this.id,
required this.lat,
@ -33,10 +32,6 @@ class YourLocation {
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(