Fix linting issues and code quality improvements
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>
This commit is contained in:
@@ -2,12 +2,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../models/delivery.dart';
|
||||
import '../models/delivery_route.dart';
|
||||
import '../providers/providers.dart';
|
||||
import '../api/client.dart';
|
||||
import '../api/openapi_config.dart';
|
||||
import '../models/delivery_commands.dart';
|
||||
import '../utils/breakpoints.dart';
|
||||
import '../components/map_sidebar_layout.dart';
|
||||
import '../components/dark_mode_map.dart';
|
||||
import '../components/delivery_list_item.dart';
|
||||
@@ -82,24 +80,8 @@ class _DeliveriesPageState extends ConsumerState<DeliveriesPage> {
|
||||
});
|
||||
}
|
||||
|
||||
final todoDeliveries = deliveries
|
||||
.where((d) => !d.delivered && !d.isSkipped)
|
||||
.toList();
|
||||
final completedDeliveries = deliveries
|
||||
.where((d) => d.delivered)
|
||||
.toList();
|
||||
|
||||
return routesData.when(
|
||||
data: (routes) {
|
||||
DeliveryRoute? currentRoute;
|
||||
try {
|
||||
currentRoute = routes.firstWhere(
|
||||
(r) => r.id == widget.routeFragmentId,
|
||||
);
|
||||
} catch (_) {
|
||||
currentRoute = routes.isNotEmpty ? routes.first : null;
|
||||
}
|
||||
|
||||
return MapSidebarLayout(
|
||||
mapWidget: DarkModeMapComponent(
|
||||
deliveries: deliveries,
|
||||
@@ -331,7 +313,7 @@ class DeliveryCard extends StatelessWidget {
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
color: isSelected
|
||||
? Theme.of(context).colorScheme.primaryContainer.withOpacity(0.3)
|
||||
? Theme.of(context).colorScheme.primaryContainer.withValues(alpha: 0.3)
|
||||
: null,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:google_navigation_flutter/google_navigation_flutter.dart';
|
||||
import 'package:planb_logistic/l10n/app_localizations.dart';
|
||||
import '../models/delivery.dart';
|
||||
import '../services/location_permission_service.dart';
|
||||
import '../components/navigation_tc_dialog.dart';
|
||||
|
||||
class NavigationPage extends ConsumerStatefulWidget {
|
||||
final Delivery delivery;
|
||||
@@ -139,38 +138,6 @@ class _NavigationPageState extends ConsumerState<NavigationPage> {
|
||||
}
|
||||
}
|
||||
|
||||
void _showPermissionDialog() {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(l10n?.locationPermissionRequired ?? 'Location Permission'),
|
||||
content: Text(
|
||||
l10n?.locationPermissionMessage ??
|
||||
'This app requires location permission to navigate to deliveries.',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
widget.onNavigationCancelled?.call();
|
||||
},
|
||||
child: Text(l10n?.cancel ?? 'Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
_requestLocationPermission();
|
||||
},
|
||||
child: Text(l10n?.requestPermission ?? 'Request Permission'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _requestLocationPermission() async {
|
||||
final result = await _permissionService.requestLocationPermission();
|
||||
|
||||
@@ -206,22 +173,19 @@ class _NavigationPageState extends ConsumerState<NavigationPage> {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(l10n?.permissionPermanentlyDenied ?? 'Permission Required'),
|
||||
content: Text(
|
||||
l10n?.openSettingsMessage ??
|
||||
'Location permission is permanently denied. Please enable it in app settings.',
|
||||
),
|
||||
title: Text(l10n.permissionPermanentlyDenied),
|
||||
content: Text(l10n.openSettingsMessage),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(l10n?.cancel ?? 'Cancel'),
|
||||
child: Text(l10n.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
_permissionService.openAppSettings();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(l10n?.openSettings ?? 'Open Settings'),
|
||||
child: Text(l10n.openSettings),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -389,7 +353,7 @@ class _NavigationPageState extends ConsumerState<NavigationPage> {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'${l10n?.navigatingTo ?? 'Navigating to'}: ${widget.delivery.name}',
|
||||
'${l10n.navigatingTo}: ${widget.delivery.name}',
|
||||
),
|
||||
elevation: 0,
|
||||
),
|
||||
@@ -417,10 +381,7 @@ class _NavigationPageState extends ConsumerState<NavigationPage> {
|
||||
children: [
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
l10n?.initializingNavigation ??
|
||||
'Initializing navigation...',
|
||||
),
|
||||
Text(l10n.initializingNavigation),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -95,7 +95,7 @@ class SettingsPage extends ConsumerWidget {
|
||||
value: language,
|
||||
onChanged: (String? newValue) {
|
||||
if (newValue != null) {
|
||||
ref.read(languageProvider.notifier).state = newValue;
|
||||
ref.read(languageProvider.notifier).setLanguage(newValue);
|
||||
}
|
||||
},
|
||||
items: const [
|
||||
@@ -122,7 +122,7 @@ class SettingsPage extends ConsumerWidget {
|
||||
SegmentedButton<ThemeMode>(
|
||||
selected: {themeMode},
|
||||
onSelectionChanged: (Set<ThemeMode> newSelection) {
|
||||
ref.read(themeModeProvider.notifier).state = newSelection.first;
|
||||
ref.read(themeModeProvider.notifier).setThemeMode(newSelection.first);
|
||||
},
|
||||
segments: const [
|
||||
ButtonSegment<ThemeMode>(
|
||||
|
||||
Reference in New Issue
Block a user