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:
Jean-Philippe Brule
2025-11-16 01:39:35 -05:00
parent d8bdaed63e
commit 57b81d1e95
14 changed files with 37 additions and 239 deletions
+9 -133
View File
@@ -26,7 +26,6 @@ class _DarkModeMapComponentState extends State<DarkModeMapComponent> {
GoogleNavigationViewController? _navigationController;
bool _isNavigating = false;
LatLng? _destinationLocation;
LatLng? _driverLocation;
bool _isSessionInitialized = false;
bool _isInitializing = false;
bool _isStartingNavigation = false;
@@ -173,126 +172,6 @@ class _DarkModeMapComponentState extends State<DarkModeMapComponent> {
}
}
String _getDarkMapStyle() {
// Google Maps style JSON for dark mode with warm accents
return '''[
{
"elementType": "geometry",
"stylers": [{"color": "#212121"}]
},
{
"elementType": "labels.icon",
"stylers": [{"visibility": "off"}]
},
{
"elementType": "labels.text.fill",
"stylers": [{"color": "#757575"}]
},
{
"elementType": "labels.text.stroke",
"stylers": [{"color": "#212121"}]
},
{
"featureType": "administrative",
"elementType": "geometry",
"stylers": [{"color": "#757575"}]
},
{
"featureType": "administrative.country",
"elementType": "labels.text.fill",
"stylers": [{"color": "#9e9e9e"}]
},
{
"featureType": "administrative.land_parcel",
"stylers": [{"visibility": "off"}]
},
{
"featureType": "administrative.locality",
"elementType": "labels.text.fill",
"stylers": [{"color": "#bdbdbd"}]
},
{
"featureType": "administrative.neighborhood",
"stylers": [{"visibility": "off"}]
},
{
"featureType": "administrative.province",
"elementType": "labels.text.fill",
"stylers": [{"color": "#9e9e9e"}]
},
{
"featureType": "landscape",
"elementType": "geometry",
"stylers": [{"color": "#000000"}]
},
{
"featureType": "poi",
"elementType": "geometry",
"stylers": [{"color": "#383838"}]
},
{
"featureType": "poi",
"elementType": "labels.text.fill",
"stylers": [{"color": "#9e9e9e"}]
},
{
"featureType": "poi.park",
"elementType": "geometry",
"stylers": [{"color": "#181818"}]
},
{
"featureType": "poi.park",
"elementType": "labels.text.fill",
"stylers": [{"color": "#616161"}]
},
{
"featureType": "road",
"elementType": "geometry.fill",
"stylers": [{"color": "#2c2c2c"}]
},
{
"featureType": "road",
"elementType": "labels.text.fill",
"stylers": [{"color": "#8a8a8a"}]
},
{
"featureType": "road.arterial",
"elementType": "geometry",
"stylers": [{"color": "#373737"}]
},
{
"featureType": "road.highway",
"elementType": "geometry",
"stylers": [{"color": "#3c3c3c"}]
},
{
"featureType": "road.highway.controlled_access",
"elementType": "geometry",
"stylers": [{"color": "#4e4e4e"}]
},
{
"featureType": "road.local",
"elementType": "labels.text.fill",
"stylers": [{"color": "#616161"}]
},
{
"featureType": "transit",
"elementType": "labels.text.fill",
"stylers": [{"color": "#757575"}]
},
{
"featureType": "water",
"elementType": "geometry",
"stylers": [{"color": "#0c1221"}]
},
{
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [{"color": "#3d3d3d"}]
}
]''';
}
Future<void> _startNavigation() async {
if (_destinationLocation == null) return;
@@ -461,9 +340,6 @@ class _DarkModeMapComponentState extends State<DarkModeMapComponent> {
// Driver's current location (defaults to Montreal if not available)
final initialPosition = const LatLng(latitude: 45.5017, longitude: -73.5673);
// Store driver location for navigation centering
_driverLocation = initialPosition;
// Calculate dynamic padding for top info panel and bottom button bar
// Increased to accommodate navigation widget info and action buttons
final topPadding = widget.selectedDelivery != null ? 110.0 : 0.0;
@@ -550,7 +426,7 @@ class _DarkModeMapComponentState extends State<DarkModeMapComponent> {
color: Theme.of(context).colorScheme.surface,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
color: Colors.black.withValues(alpha: 0.2),
blurRadius: 8,
offset: const Offset(0, 2),
),
@@ -631,7 +507,7 @@ class _DarkModeMapComponentState extends State<DarkModeMapComponent> {
color: Theme.of(context).colorScheme.surface,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
color: Colors.black.withValues(alpha: 0.2),
blurRadius: 8,
offset: const Offset(0, -2),
),
@@ -700,7 +576,7 @@ class _DarkModeMapComponentState extends State<DarkModeMapComponent> {
if (_isStartingNavigation || _isInitializing)
Positioned.fill(
child: Container(
color: Colors.black.withOpacity(0.4),
color: Colors.black.withValues(alpha: 0.4),
child: Center(
child: Container(
padding: const EdgeInsets.all(24),
@@ -709,7 +585,7 @@ class _DarkModeMapComponentState extends State<DarkModeMapComponent> {
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
color: Colors.black.withValues(alpha: 0.3),
blurRadius: 12,
offset: const Offset(0, 4),
),
@@ -743,7 +619,7 @@ class _DarkModeMapComponentState extends State<DarkModeMapComponent> {
Text(
'Please wait...',
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7),
),
textAlign: TextAlign.center,
),
@@ -766,7 +642,7 @@ class _DarkModeMapComponentState extends State<DarkModeMapComponent> {
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
color: Colors.black.withValues(alpha: 0.3),
blurRadius: 4,
offset: const Offset(0, 2),
),
@@ -812,7 +688,7 @@ class _DarkModeMapComponentState extends State<DarkModeMapComponent> {
// Reduce opacity when disabled
if (onPressed == null) {
backgroundColor = backgroundColor.withOpacity(0.5);
backgroundColor = backgroundColor.withValues(alpha: 0.5);
}
return Material(
@@ -858,7 +734,7 @@ class _DarkModeMapComponentState extends State<DarkModeMapComponent> {
required Color color,
}) {
final isDisabled = onPressed == null;
final buttonColor = isDisabled ? color.withOpacity(0.5) : color;
final buttonColor = isDisabled ? color.withValues(alpha: 0.5) : color;
return Container(
margin: const EdgeInsets.only(bottom: 8),
@@ -866,7 +742,7 @@ class _DarkModeMapComponentState extends State<DarkModeMapComponent> {
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
color: Colors.black.withValues(alpha: 0.3),
blurRadius: 4,
offset: const Offset(0, 2),
),
+5 -6
View File
@@ -115,15 +115,15 @@ class _DeliveryListItemState extends State<DeliveryListItem>
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: widget.delivery.delivered
? Colors.green.withOpacity(0.15)
? Colors.green.withValues(alpha: 0.15)
: (_isHovered || widget.isSelected
? Theme.of(context).colorScheme.surfaceContainer
: Colors.transparent),
boxShadow: (_isHovered || widget.isSelected) && !widget.delivery.delivered
? [
BoxShadow(
color: Colors.black.withOpacity(
isDark ? 0.3 : 0.08,
color: Colors.black.withValues(
alpha: isDark ? 0.3 : 0.08,
),
blurRadius: 8,
offset: const Offset(0, 4),
@@ -256,14 +256,13 @@ class _DeliveryListItemState extends State<DeliveryListItem>
],
),
// Total amount (if present)
if (widget.delivery.orders.isNotEmpty &&
widget.delivery.orders.first.totalAmount != null)
if (widget.delivery.orders.isNotEmpty)
Padding(
padding: const EdgeInsets.only(top: 8, left: 16),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Total: \$${widget.delivery.orders.first.totalAmount!.toStringAsFixed(2)}',
'Total: \$${widget.delivery.orders.first.totalAmount.toStringAsFixed(2)}',
style: Theme.of(context)
.textTheme
.labelSmall
@@ -28,7 +28,6 @@ class GlassmorphicRouteCard extends StatefulWidget {
class _GlassmorphicRouteCardState extends State<GlassmorphicRouteCard>
with SingleTickerProviderStateMixin {
late AnimationController _hoverController;
bool _isHovered = false;
@override
void initState() {
@@ -72,9 +71,6 @@ class _GlassmorphicRouteCardState extends State<GlassmorphicRouteCard>
}
void _setHovered(bool hovered) {
setState(() {
_isHovered = hovered;
});
if (hovered) {
_hoverController.forward();
} else {
+1 -4
View File
@@ -24,7 +24,6 @@ class _PremiumRouteCardState extends State<PremiumRouteCard>
late AnimationController _controller;
late Animation<double> _scaleAnimation;
late Animation<double> _shadowAnimation;
bool _isHovered = false;
@override
void initState() {
@@ -50,12 +49,10 @@ class _PremiumRouteCardState extends State<PremiumRouteCard>
}
void _onHoverEnter() {
setState(() => _isHovered = true);
_controller.forward();
}
void _onHoverExit() {
setState(() => _isHovered = false);
_controller.reverse();
}
@@ -81,7 +78,7 @@ class _PremiumRouteCardState extends State<PremiumRouteCard>
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(isDark ? 0.3 : 0.1),
color: Colors.black.withValues(alpha: isDark ? 0.3 : 0.1),
blurRadius: _shadowAnimation.value,
offset: Offset(0, _shadowAnimation.value * 0.5),
),