Skip to content

Commit 86e0d65

Browse files
authored
Merge pull request #34 from dougborg/pr/02-lint-cleanup
Add flutter_lints and fix all analyzer warnings
2 parents a149562 + 3570104 commit 86e0d65

77 files changed

Lines changed: 225 additions & 334 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/app_state.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'dart:async';
22
import 'dart:convert';
33
import 'package:flutter/material.dart';
4-
import 'package:flutter/foundation.dart';
54
import 'package:flutter_map/flutter_map.dart' show LatLngBounds;
65
import 'package:http/http.dart' as http;
76
import 'package:latlong2/latlong.dart';
@@ -23,7 +22,6 @@ import 'services/operator_profile_service.dart';
2322
import 'services/deep_link_service.dart';
2423
import 'widgets/node_provider_with_cache.dart';
2524
import 'services/profile_service.dart';
26-
import 'widgets/proximity_warning_dialog.dart';
2725
import 'widgets/reauth_messages_dialog.dart';
2826
import 'dev_config.dart';
2927
import 'state/auth_state.dart';
@@ -366,6 +364,7 @@ class AppState extends ChangeNotifier {
366364
/// Show re-authentication dialog if needed
367365
Future<void> checkAndPromptReauthForMessages(BuildContext context) async {
368366
if (await needsReauthForMessages()) {
367+
if (!context.mounted) return;
369368
_showReauthDialog(context);
370369
}
371370
}

lib/migrations.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'dart:convert';
2-
import 'package:flutter/foundation.dart';
32
import 'package:flutter/material.dart';
43
import 'package:shared_preferences/shared_preferences.dart';
54

@@ -147,7 +146,7 @@ class OneTimeMigrations {
147146
debugPrint('[Migration] Stack trace: $stackTrace');
148147

149148
// Nuclear option: clear everything and show non-dismissible error dialog
150-
if (context != null) {
149+
if (context != null && context.mounted) {
151150
NuclearResetDialog.show(context, error, stackTrace);
152151
} else {
153152
// If no context available, just log and hope for the best

lib/models/direction_fov.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class DirectionFov {
99
DirectionFov(this.centerDegrees, this.fovDegrees);
1010

1111
@override
12-
String toString() => 'DirectionFov(center: ${centerDegrees}°, fov: ${fovDegrees}°)';
12+
String toString() => 'DirectionFov(center: $centerDegrees°, fov: $fovDegrees°)';
1313

1414
@override
1515
bool operator ==(Object other) =>

lib/models/node_profile.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:uuid/uuid.dart';
21
import 'osm_node.dart';
32

43
/// Sentinel value for copyWith methods to distinguish between null and not provided

lib/models/operator_profile.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:uuid/uuid.dart';
21
import 'osm_node.dart';
32

43
/// A bundle of OSM tags that describe a particular surveillance operator.

lib/models/suspected_location.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:convert';
2+
import 'package:flutter/foundation.dart';
23
import 'package:latlong2/latlong.dart';
34

45
/// A suspected surveillance location from the CSV data
@@ -35,8 +36,8 @@ class SuspectedLocation {
3536
bounds = coordinates.bounds;
3637
} catch (e) {
3738
// If GeoJSON parsing fails, use default coordinates
38-
print('[SuspectedLocation] Failed to parse GeoJSON for ticket $ticketNo: $e');
39-
print('[SuspectedLocation] Location string: $locationString');
39+
debugPrint('[SuspectedLocation] Failed to parse GeoJSON for ticket $ticketNo: $e');
40+
debugPrint('[SuspectedLocation] Location string: $locationString');
4041
}
4142
}
4243

@@ -60,7 +61,7 @@ class SuspectedLocation {
6061
// The geoJson IS the geometry object (not wrapped in a 'geometry' property)
6162
final coordinates = geoJson['coordinates'] as List?;
6263
if (coordinates == null || coordinates.isEmpty) {
63-
print('[SuspectedLocation] No coordinates found in GeoJSON');
64+
debugPrint('[SuspectedLocation] No coordinates found in GeoJSON');
6465
return (centroid: const LatLng(0, 0), bounds: <LatLng>[]);
6566
}
6667

@@ -109,7 +110,7 @@ class SuspectedLocation {
109110
}
110111
break;
111112
default:
112-
print('Unsupported geometry type: $type');
113+
debugPrint('Unsupported geometry type: $type');
113114
}
114115

115116
if (points.isEmpty) {
@@ -127,7 +128,7 @@ class SuspectedLocation {
127128

128129
return (centroid: centroid, bounds: points);
129130
} catch (e) {
130-
print('Error extracting coordinates from GeoJSON: $e');
131+
debugPrint('Error extracting coordinates from GeoJSON: $e');
131132
return (centroid: const LatLng(0, 0), bounds: <LatLng>[]);
132133
}
133134
}

lib/screens/advanced_settings_screen.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import 'settings/sections/max_nodes_section.dart';
33
import 'settings/sections/proximity_alerts_section.dart';
44
import 'settings/sections/suspected_locations_section.dart';
55
import 'settings/sections/tile_provider_section.dart';
6-
import 'settings/sections/network_status_section.dart';
76
import '../services/localization_service.dart';
87

98
class AdvancedSettingsScreen extends StatelessWidget {

lib/screens/coordinators/sheet_coordinator.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import '../../widgets/add_node_sheet.dart';
99
import '../../widgets/edit_node_sheet.dart';
1010
import '../../widgets/navigation_sheet.dart';
1111
import '../../widgets/measured_sheet.dart';
12-
import '../../state/settings_state.dart' show FollowMeMode;
1312

1413
/// Coordinates all bottom sheet operations including opening, closing, height tracking,
1514
/// and sheet-related validation logic.
@@ -118,9 +117,8 @@ class SheetCoordinator {
118117
controller.closed.then((_) {
119118
_addSheetHeight = 0.0;
120119
onStateChanged();
121-
120+
122121
// Handle dismissal by canceling session if still active
123-
final appState = context.read<AppState>();
124122
if (appState.session != null) {
125123
debugPrint('[SheetCoordinator] AddNodeSheet dismissed - canceling session');
126124
appState.cancelSession();
@@ -187,9 +185,8 @@ class SheetCoordinator {
187185
_editSheetHeight = 0.0;
188186
_transitioningToEdit = false;
189187
onStateChanged();
190-
188+
191189
// Handle dismissal by canceling session if still active
192-
final appState = context.read<AppState>();
193190
if (appState.editSession != null) {
194191
debugPrint('[SheetCoordinator] EditNodeSheet dismissed - canceling edit session');
195192
appState.cancelEditSession();
@@ -266,7 +263,7 @@ class SheetCoordinator {
266263
/// Restore the follow-me mode that was active before opening a node sheet
267264
void _restoreFollowMeMode(AppState appState) {
268265
if (_followMeModeBeforeSheet != null) {
269-
debugPrint('[SheetCoordinator] Restoring follow-me mode: ${_followMeModeBeforeSheet}');
266+
debugPrint('[SheetCoordinator] Restoring follow-me mode: $_followMeModeBeforeSheet');
270267
appState.setFollowMeMode(_followMeModeBeforeSheet!);
271268
_followMeModeBeforeSheet = null; // Clear stored state
272269
}

lib/screens/home_screen.dart

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter_map/flutter_map.dart';
32
import 'package:flutter_map_animations/flutter_map_animations.dart';
43
import 'package:flutter_svg/flutter_svg.dart';
5-
import 'package:latlong2/latlong.dart';
64
import 'package:provider/provider.dart';
75

86
import '../app_state.dart';
97
import '../dev_config.dart';
108
import '../widgets/map_view.dart';
119
import '../services/localization_service.dart';
1210

13-
import '../widgets/add_node_sheet.dart';
14-
import '../widgets/edit_node_sheet.dart';
1511
import '../widgets/node_tag_sheet.dart';
1612
import '../widgets/download_area_dialog.dart';
1713
import '../widgets/measured_sheet.dart';
18-
import '../widgets/navigation_sheet.dart';
1914
import '../widgets/search_bar.dart';
2015
import '../widgets/suspected_location_sheet.dart';
2116
import '../widgets/welcome_dialog.dart';
@@ -190,6 +185,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
190185

191186
// Run any needed migrations first
192187
final versionsNeedingMigration = await ChangelogService().getVersionsNeedingMigration();
188+
if (!mounted) return;
193189
for (final version in versionsNeedingMigration) {
194190
await ChangelogService().runMigration(version, appState, context);
195191
}
@@ -214,6 +210,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
214210

215211
case PopupType.changelog:
216212
final changelogContent = await ChangelogService().getChangelogContentForDisplay();
213+
if (!mounted) return;
217214
if (changelogContent != null) {
218215
await showDialog(
219216
context: context,
@@ -252,35 +249,6 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
252249
);
253250
}
254251

255-
void _zoomAndCenterForRoute(bool followMeEnabled, LatLng? userLocation, LatLng? routeStart) {
256-
try {
257-
LatLng centerLocation;
258-
259-
if (followMeEnabled && userLocation != null) {
260-
// Center on user if follow-me is enabled
261-
centerLocation = userLocation;
262-
debugPrint('[HomeScreen] Centering on user location for route start');
263-
} else if (routeStart != null) {
264-
// Center on start pin if user is far away or no GPS
265-
centerLocation = routeStart;
266-
debugPrint('[HomeScreen] Centering on route start pin');
267-
} else {
268-
debugPrint('[HomeScreen] No valid location to center on');
269-
return;
270-
}
271-
272-
// Animate to zoom 14 and center location
273-
_mapController.animateTo(
274-
dest: centerLocation,
275-
zoom: 14.0,
276-
duration: const Duration(milliseconds: 800),
277-
curve: Curves.easeInOut,
278-
);
279-
} catch (e) {
280-
debugPrint('[HomeScreen] Could not zoom/center for route: $e');
281-
}
282-
}
283-
284252
void _onResumeRoute() {
285253
_navigationCoordinator.resumeRoute(
286254
context: context,
@@ -402,9 +370,11 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
402370
);
403371

404372
// Reset height and clear selection when sheet is dismissed
373+
final appState = context.read<AppState>();
405374
controller.closed.then((_) {
375+
if (!mounted) return;
406376
_sheetCoordinator.resetTagSheetHeight(() => setState(() {}));
407-
context.read<AppState>().clearSuspectedLocationSelection();
377+
appState.clearSuspectedLocationSelection();
408378
});
409379
}
410380

@@ -578,7 +548,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
578548
borderRadius: BorderRadius.circular(16),
579549
boxShadow: [
580550
BoxShadow(
581-
color: Theme.of(context).shadowColor.withOpacity(0.3),
551+
color: Theme.of(context).shadowColor.withValues(alpha: 0.3),
582552
blurRadius: 10,
583553
offset: Offset(0, -2),
584554
)

lib/screens/navigation_settings_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class _NavigationSettingsScreenState extends State<NavigationSettingsScreen> {
132132
Text(
133133
value,
134134
style: Theme.of(context).textTheme.bodySmall?.copyWith(
135-
color: Theme.of(context).textTheme.bodySmall?.color?.withOpacity(0.6),
135+
color: Theme.of(context).textTheme.bodySmall?.color?.withValues(alpha: 0.6),
136136
),
137137
),
138138
const SizedBox(width: 8),

0 commit comments

Comments
 (0)