Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ linter:
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
avoid_print: true
prefer_final_fields: true
avoid_catches_without_on_clauses: true
curly_braces_in_flow_control_structures: true
control_flow_in_finally: true
4 changes: 2 additions & 2 deletions lib/config/runtime_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class RuntimeConfig {
static Future<void> bootstrap() async {
try {
dotenv.env.clear();
} catch (_) {}
} on Object catch (_) {}

if (!kReleaseMode) {
try {
await dotenv.load(fileName: '.env');
appLog.i('Loaded local .env for development');
} catch (_) {}
} on Object catch (_) {}
}

// ── Backend / cloud ────────────────────────────────────────────────────
Expand Down
10 changes: 5 additions & 5 deletions lib/database/app_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Future<void> bootstrapSupabaseAuth() async {
await ensureSupabaseAnonymousSession(Supabase.instance.client);
_supabaseSdkInitialized = true;
appLog.i('Supabase anonymous sign-in completed.');
} catch (e, st) {
} on Object catch (e, st) {
_supabaseSdkInitialized = false;
appLog.e('Supabase bootstrap failed', error: e, stackTrace: st);
}
Expand All @@ -53,7 +53,7 @@ Future<void> ensureSupabaseAnonymousSession(SupabaseClient client) async {
if (after != null && !after.isExpired) {
return;
}
} catch (e, st) {
} on Object catch (e, st) {
appLog.w(
'Session refresh failed; re-authenticating',
error: e,
Expand All @@ -62,7 +62,7 @@ Future<void> ensureSupabaseAnonymousSession(SupabaseClient client) async {
}
}
await client.auth.signInAnonymously();
} catch (e, st) {
} on Object catch (e, st) {
appLog.w('Anonymous auth failed', error: e, stackTrace: st);
}
}
Expand Down Expand Up @@ -107,7 +107,7 @@ class SupabaseConnector extends PowerSyncBackendConnector {
}
}
await transaction.complete();
} catch (e, st) {
} on Object catch (e, st) {
appLog.e('PowerSync upload error', error: e, stackTrace: st);
}
}
Expand Down Expand Up @@ -163,7 +163,7 @@ Future<void> initializeDatabase() async {
appDb.connect(connector: SupabaseConnector(Supabase.instance.client));
_dbInitialized = true;
appLog.i('PowerSync + Supabase initialized.');
} catch (e, st) {
} on Object catch (e, st) {
appLog.e('Database initialization failed', error: e, stackTrace: st);
_dbInitialized = false;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void main() async {
// reads its configuration keys.
try {
await RuntimeConfig.bootstrap();
} catch (e, st) {
} on Object catch (e, st) {
// Non-fatal: all services check for missing config and degrade gracefully.
appLog.w(
'[boot] RuntimeConfig.bootstrap() failed — proceeding without config',
Expand Down Expand Up @@ -158,7 +158,7 @@ class _RoadSOSAppState extends ConsumerState<RoadSOSApp>
if (_servicesReady && accepted) {
_runPostConsentHooks();
}
} catch (e, st) {
} on Object catch (e, st) {
appLog.e('[boot] Privacy check failed', error: e, stackTrace: st);
if (mounted) setState(() => _privacyReady = true); // unblock UI
}
Expand Down Expand Up @@ -191,7 +191,7 @@ class _RoadSOSAppState extends ConsumerState<RoadSOSApp>
);

appLog.i('[boot] All services bootstrapped successfully.');
} catch (e, st) {
} on Object catch (e, st) {
// Non-fatal: app runs in offline/degraded mode.
appLog.e(
'[boot] Service bootstrap error — running in degraded mode',
Expand Down
8 changes: 4 additions & 4 deletions lib/services/agent_health_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class AgentHealthService {
_gemmaCloudCached = result;
_gemmaCloudCachedAt = DateTime.now();
return result;
} catch (e) {
} on Object catch (e) {
appLog.d('[HealthCheck] Gemma cloud probe failed: $e');
_gemmaCloudCached = AgentReadiness.degraded;
_gemmaCloudCachedAt = DateTime.now();
Expand All @@ -215,7 +215,7 @@ class AgentHealthService {
return AgentReadiness.unavailable;
}
return AgentReadiness.ready;
} catch (_) {
} on Object catch (_) {
return AgentReadiness.degraded;
}
}
Expand All @@ -232,7 +232,7 @@ class AgentHealthService {
// Fallback: open SMS app intent (no permission). If relay isn't configured,
// we mark this as degraded (still usable, but requires user interaction).
return AgentReadiness.degraded;
} catch (_) {
} on Object catch (_) {
return AgentReadiness.degraded;
}
}
Expand All @@ -241,7 +241,7 @@ class AgentHealthService {
try {
final status = await Permission.bluetooth.status;
return status.isGranted ? AgentReadiness.ready : AgentReadiness.degraded;
} catch (_) {
} on Object catch (_) {
return AgentReadiness.degraded;
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/services/ai_triage_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class AiTriageService {
).timeout(cloudTimeout);
appLog.i('[Triage] Tier 1 — Gemma 4 27B cloud ✓ (text-only auto-SOS)');
return cloud;
} catch (e, st) {
} on Object catch (e, st) {
appLog.d(
'[Triage] Tier 1 unavailable, trying Tier 2 on-device',
error: e,
Expand All @@ -253,7 +253,7 @@ class AiTriageService {
appLog.i('[Triage] Tier 2 — Gemma 4 E4B on-device ✓');
return onDevice;
}
} catch (e, st) {
} on Object catch (e, st) {
appLog.d('[Triage] Tier 2 on-device failed', error: e, stackTrace: st);
}
}
Expand Down Expand Up @@ -313,7 +313,7 @@ class AiTriageService {
'(${scenePhoto.sizeKb} KB · source=${cloud.source.name})',
);
return cloud;
} catch (e, st) {
} on Object catch (e, st) {
appLog.d(
'[Triage] Vision cloud failed — falling back to text-only triage',
error: e,
Expand Down
4 changes: 2 additions & 2 deletions lib/services/bluetooth_vehicle_monitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ class BluetoothVehicleMonitor {
_lastSpeedKmh = (p.speed * 3.6).clamp(0.0, 320.0);
}
}, onError: (Object _) {});
} catch (_) {}
} on Object catch (_) {}
}

void _poll() {
List<BluetoothDevice> devices;
try {
devices = FlutterBluePlus.connectedDevices;
} catch (_) {
} on Object catch (_) {
return; // BT not available on this device.
}

Expand Down
10 changes: 5 additions & 5 deletions lib/services/bystander_coach_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Response rules:
_sttReady = await _stt.initialize(
onError: (e) => appLog.w('[BystanderCoach] STT error: ${e.errorMsg}'),
);
} catch (e, st) {
} on Object catch (e, st) {
appLog.w('[BystanderCoach] STT init failed', error: e, stackTrace: st);
_sttReady = false;
}
Expand Down Expand Up @@ -201,7 +201,7 @@ Response rules:
Future<void> _stopListeningSafely() async {
try {
if (_stt.isListening) await _stt.stop();
} catch (_) {}
} on Object catch (_) {}
}

// ─── Core response loop ───────────────────────────────────────────────────
Expand Down Expand Up @@ -229,7 +229,7 @@ Response rules:

try {
await _ref.read(voiceAssistantServiceProvider).speak(reply);
} catch (e, st) {
} on Object catch (e, st) {
appLog.d('[BystanderCoach] TTS speak failed', stackTrace: st);
}
state = state.copyWith(phase: BystanderCoachPhase.idle);
Expand Down Expand Up @@ -353,7 +353,7 @@ Response rules:
Future<String> _firstAidGrounding(String query) async {
try {
return await FirstAidRepository.instance.lookup(query);
} catch (e, st) {
} on Object catch (e, st) {
appLog.d('[BystanderCoach] first-aid lookup failed', stackTrace: st);
return '';
}
Expand Down Expand Up @@ -521,7 +521,7 @@ Response rules:
if (gemma.isAvailable) {
out = await gemma.generate(prompt).timeout(const Duration(seconds: 20));
}
} catch (e, st) {
} on Object catch (e, st) {
appLog.d('[BystanderCoach] gemma generate failed', stackTrace: st);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/services/camera_triage_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class CameraTriageService {
sizeBytes: bytes.length,
capturedAt: DateTime.now().toUtc(),
);
} catch (e, st) {
} on Object catch (e, st) {
appLog.w(
'[CameraTriageService] Image selection failed',
error: e,
Expand Down Expand Up @@ -132,7 +132,7 @@ class CameraTriageService {
sizeBytes: bytes.length,
capturedAt: DateTime.now().toUtc(),
);
} catch (e) {
} on Object catch (e) {
appLog.d('[CameraTriageService] Silent capture failed: $e');
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/services/crash_detection_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class CrashDetectionService {
distanceFilter: 0,
),
).listen(_onPosition, onError: (Object _) => _gpsSpeedUsable = false);
} catch (_) {
} on Object catch (_) {
_gpsSpeedUsable = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/services/driving_mode_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class DrivingModeService extends StateNotifier<DrivingMode> {
distanceFilter: 20,
),
).listen(_onPosition, onError: (Object _) {});
} catch (_) {}
} on Object catch (_) {}
}

void _onPosition(Position p) {
Expand Down
4 changes: 2 additions & 2 deletions lib/services/emergency_background_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class EmergencyBackgroundService {
);
_initialized = true;
appLog.i('[BgService] Foreground service configured.');
} catch (e, st) {
} on Object catch (e, st) {
appLog.w('[BgService] Configure failed', error: e, stackTrace: st);
}
}
Expand Down Expand Up @@ -159,7 +159,7 @@ class EmergencyBackgroundService {
} else {
appLog.d('[BgService] Battery optimization exemption already granted.');
}
} catch (e) {
} on Object catch (e) {
appLog.w('[BgService] Battery exemption request failed: $e');
}
}
Expand Down
10 changes: 5 additions & 5 deletions lib/services/emergency_beacon_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ class EmergencyBeaconService {

try {
await TorchLight.disableTorch();
} catch (_) {}
} on Object catch (_) {}

try {
await _player.stop();
} catch (_) {}
} on Object catch (_) {}

appLog.i('✅ [BEACON] Hardware SOS signals disabled.');
}
Expand Down Expand Up @@ -95,7 +95,7 @@ class EmergencyBeaconService {
if (kIsWeb) return;
try {
await TorchLight.enableTorch();
} catch (e) {
} on Object catch (e) {
appLog.w('[BEACON] Failed to enable torch', error: e);
}
}
Expand All @@ -104,7 +104,7 @@ class EmergencyBeaconService {
if (kIsWeb) return;
try {
await TorchLight.disableTorch();
} catch (e) {
} on Object catch (e) {
appLog.w('[BEACON] Failed to disable torch', error: e);
}
}
Expand All @@ -118,7 +118,7 @@ class EmergencyBeaconService {
await _player.setLoopMode(LoopMode.one);
await _player.setVolume(1.0);
await _player.play();
} catch (e) {
} on Object catch (e) {
appLog.d('[BEACON] Siren failed to play: $e');
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/services/emergency_notification_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class EmergencyNotificationService {
),
),
);
} catch (e, st) {
} on Object catch (e, st) {
appLog.w('Emergency local notification failed', error: e, stackTrace: st);
}
}
Expand All @@ -84,6 +84,6 @@ class EmergencyNotificationService {
if (kIsWeb) return;
try {
await _local.cancel(id: _sosActiveNotificationId);
} catch (_) {}
} on Object catch (_) {}
}
}
Loading
Loading