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:
parent
23838069c2
commit
ea588a9753
25 changed files with 83 additions and 161 deletions
|
|
@ -31,7 +31,6 @@ import 'zoomMapPlugin.dart';
|
|||
|
||||
@immutable
|
||||
class _ViewModel {
|
||||
|
||||
const _ViewModel(
|
||||
{required this.mapState,
|
||||
required this.serverUrl,
|
||||
|
|
@ -96,7 +95,6 @@ class _genericMapState extends State<genericMap> {
|
|||
_initialLocation = _location?.copyWith();
|
||||
},
|
||||
converter: (Store<AppState> store) {
|
||||
print('New map viewer');
|
||||
return _ViewModel(
|
||||
onSubs: (YourLocation loc) {
|
||||
store.dispatch(SubscribeAction());
|
||||
|
|
@ -112,7 +110,8 @@ class _genericMapState extends State<genericMap> {
|
|||
onSlide: (YourLocation loc) {
|
||||
store.dispatch(UpdateYourLocationMapAction(loc));
|
||||
},
|
||||
onEdit: (YourLocation loc) => store.dispatch(EditYourLocationAction(loc)),
|
||||
onEdit: (YourLocation loc) =>
|
||||
store.dispatch(EditYourLocationAction(loc)),
|
||||
onEditing: (YourLocation loc) {
|
||||
store.dispatch(UpdateYourLocationMapAction(loc));
|
||||
},
|
||||
|
|
@ -123,8 +122,9 @@ class _genericMapState extends State<genericMap> {
|
|||
store.dispatch(UpdateYourLocationMapAction(loc));
|
||||
store.dispatch(EditConfirmYourLocationAction(loc));
|
||||
},
|
||||
onFalsePositive: (FireNotification notif, FalsePositiveType type) => store
|
||||
.dispatch(MarkFireAsFalsePositiveAction(notif, type)),
|
||||
onFalsePositive: (FireNotification notif,
|
||||
FalsePositiveType type) =>
|
||||
store.dispatch(MarkFireAsFalsePositiveAction(notif, type)),
|
||||
onFirePressed: (LatLng latLng, DateTime when, String type) {
|
||||
_showFireDialog(latLng, when, type);
|
||||
},
|
||||
|
|
@ -136,18 +136,15 @@ class _genericMapState extends State<genericMap> {
|
|||
builder: (BuildContext context, _ViewModel view) {
|
||||
final YourLocation? location = view.mapState.yourLocation;
|
||||
_location = location?.copyWith();
|
||||
print('New map builder with ${_location?.description}');
|
||||
|
||||
final FireMapState mapState = view.mapState;
|
||||
final FireMapStatus status = mapState.status;
|
||||
final FireMapLayer layer = mapState.layer;
|
||||
print('Build map with status: $status and layer $layer');
|
||||
|
||||
const double maxZoom = 18.0; // works?
|
||||
|
||||
final MapOptions mapOptions = MapOptions(
|
||||
initialCenter:
|
||||
LatLng(_location?.lat ?? 0.0, _location?.lon ?? 0.0),
|
||||
initialCenter: LatLng(_location?.lat ?? 0.0, _location?.lon ?? 0.0),
|
||||
maxZoom: maxZoom,
|
||||
onTap: (TapPosition tapPosition, LatLng latLng) {
|
||||
if (status == FireMapStatus.edit && _location != null) {
|
||||
|
|
@ -221,11 +218,11 @@ class _genericMapState extends State<genericMap> {
|
|||
urlTemplate: baseLayer,
|
||||
subdomains: subdomains,
|
||||
userAgentPackageName: 'com.example.fires_flutter',
|
||||
additionalOptions: const <String, String> {
|
||||
// 'opacity': '0.1',
|
||||
},
|
||||
),
|
||||
if (globals.isDevelopment) const ZoomMapPluginWidget() else const DummyMapPluginWidget(),
|
||||
if (globals.isDevelopment)
|
||||
const ZoomMapPluginWidget()
|
||||
else
|
||||
const DummyMapPluginWidget(),
|
||||
const CompassMapPluginWidget(),
|
||||
MarkerLayer(
|
||||
markers: buildMarkers(
|
||||
|
|
@ -316,8 +313,9 @@ class _genericMapState extends State<genericMap> {
|
|||
onSave: () => view.onEditConfirm(_location!),
|
||||
onCancel: () =>
|
||||
view.onEditCancel(_initialLocation ?? _location!),
|
||||
onFalsePositive: (FireNotification sealed, FalsePositiveType type) =>
|
||||
view.onFalsePositive(sealed, type),
|
||||
onFalsePositive:
|
||||
(FireNotification sealed, FalsePositiveType type) =>
|
||||
view.onFalsePositive(sealed, type),
|
||||
state: view.mapState,
|
||||
scaffoldKey: _scaffoldKey,
|
||||
),
|
||||
|
|
@ -347,8 +345,7 @@ class _genericMapState extends State<genericMap> {
|
|||
? <Widget>[
|
||||
FireDistanceSlider(
|
||||
initialValue:
|
||||
_location?.distance ?? 0
|
||||
,
|
||||
_location?.distance ?? 0,
|
||||
onSlide: (int distance) {
|
||||
if (_location != null) {
|
||||
_location!.distance = distance;
|
||||
|
|
@ -400,12 +397,12 @@ class _genericMapState extends State<genericMap> {
|
|||
bool isNotif,
|
||||
OnFirePressedInMap onFirePressed) {
|
||||
final List<Marker> markers = <Marker>[];
|
||||
print(
|
||||
'building markers: fires: ${fires.length} falsePos: ${falsePosList.length} industries: ${industries.length}, isNotif: $isNotif ');
|
||||
// Debug: building markers: fires: ${fires.length} falsePos: ${falsePosList.length} industries: ${industries.length}, isNotif: $isNotif
|
||||
// const calibrate = false; // useful when we change the fire icons size
|
||||
for (final falsePos in falsePosList) {
|
||||
for (final falsePos in falsePosList) {
|
||||
try {
|
||||
final List<dynamic> coords = falsePos['geo']['coordinates'] as List<dynamic>;
|
||||
final List<dynamic> coords =
|
||||
falsePos['geo']['coordinates'] as List<dynamic>;
|
||||
// print('false pos: ${coords}');
|
||||
final LatLng loc = LatLng(
|
||||
(coords[1] as num).toDouble(), (coords[0] as num).toDouble());
|
||||
|
|
@ -414,14 +411,14 @@ class _genericMapState extends State<genericMap> {
|
|||
}));
|
||||
// if (calibrate) markers.add(FireMarker(loc, FireMarkType.pixel));
|
||||
} catch (e, stackTrace) {
|
||||
print('Failed to process $falsePos');
|
||||
reportError(e, stackTrace);
|
||||
}
|
||||
}
|
||||
for (final industry in industries) {
|
||||
for (final industry in industries) {
|
||||
try {
|
||||
// print(fire['geo']['coordinates']);
|
||||
final List<dynamic> coords = industry['geo']['coordinates'] as List<dynamic>;
|
||||
final List<dynamic> coords =
|
||||
industry['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, () {
|
||||
|
|
@ -429,22 +426,19 @@ class _genericMapState extends State<genericMap> {
|
|||
}));
|
||||
// if (calibrate) markers.add(FireMarker(loc, FireMarkType.pixel));
|
||||
} catch (e, stackTrace) {
|
||||
print('Failed to process $industry');
|
||||
reportError(e, stackTrace);
|
||||
}
|
||||
}
|
||||
for (final fire in fires) {
|
||||
for (final 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);
|
||||
print('fire $fire pressed');
|
||||
}));
|
||||
markers.add(FireMarker(loc, FireMarkType.pixel));
|
||||
} catch (e, stackTrace) {
|
||||
print('Failed to process $fire');
|
||||
reportError(e, stackTrace);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue