Resolve 62 linting issues identified by flutter analyze, reducing total issues from 79 to 17. All critical warnings addressed. Changes: - Replace deprecated withOpacity() with withValues(alpha:) (25 instances) - Remove unused imports from 9 files - Remove unused variables and fields (6 instances) - Fix Riverpod 3.0 state access violations in settings_page - Remove unnecessary null-aware operators in navigation_page (6 instances) - Fix unnecessary type casts in providers (4 instances) - Remove unused methods: _getDarkMapStyle, _showPermissionDialog - Simplify hover state management by removing unused _isHovered fields Remaining 17 issues are info-level style suggestions and defensive programming patterns that don't impact functionality. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
69 lines
1.9 KiB
Dart
69 lines
1.9 KiB
Dart
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
class LocationPermissionService {
|
|
Future<LocationPermissionResult> requestLocationPermission() async {
|
|
final status = await Permission.location.request();
|
|
|
|
return switch (status) {
|
|
PermissionStatus.granted => LocationPermissionResult.granted(),
|
|
PermissionStatus.denied => LocationPermissionResult.denied(),
|
|
PermissionStatus.permanentlyDenied =>
|
|
LocationPermissionResult.permanentlyDenied(),
|
|
_ => LocationPermissionResult.error(
|
|
message: 'Unexpected permission status: $status',
|
|
),
|
|
};
|
|
}
|
|
|
|
Future<bool> hasLocationPermission() async {
|
|
final status = await Permission.location.status;
|
|
return status.isGranted;
|
|
}
|
|
|
|
Future<void> openAppSettings() async {
|
|
await openAppSettings();
|
|
}
|
|
}
|
|
|
|
sealed class LocationPermissionResult {
|
|
const LocationPermissionResult();
|
|
|
|
factory LocationPermissionResult.granted() => _Granted();
|
|
factory LocationPermissionResult.denied() => _Denied();
|
|
factory LocationPermissionResult.permanentlyDenied() =>
|
|
_PermanentlyDenied();
|
|
factory LocationPermissionResult.error({required String message}) =>
|
|
_Error(message);
|
|
|
|
R when<R>({
|
|
required R Function() granted,
|
|
required R Function() denied,
|
|
required R Function() permanentlyDenied,
|
|
required R Function(String message) error,
|
|
}) {
|
|
return switch (this) {
|
|
_Granted() => granted(),
|
|
_Denied() => denied(),
|
|
_PermanentlyDenied() => permanentlyDenied(),
|
|
_Error(:final message) => error(message),
|
|
};
|
|
}
|
|
}
|
|
|
|
final class _Granted extends LocationPermissionResult {
|
|
const _Granted();
|
|
}
|
|
|
|
final class _Denied extends LocationPermissionResult {
|
|
const _Denied();
|
|
}
|
|
|
|
final class _PermanentlyDenied extends LocationPermissionResult {
|
|
const _PermanentlyDenied();
|
|
}
|
|
|
|
final class _Error extends LocationPermissionResult {
|
|
final String message;
|
|
const _Error(this.message);
|
|
}
|