Resolve all lints and deprecation warnings

This commit is contained in:
2026-01-09 10:04:51 -06:00
parent 512577b092
commit a799e9cf59
56 changed files with 2819 additions and 3159 deletions

View File

@@ -3,7 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:google_fonts/google_fonts.dart';
import '../../theme/app_theme.dart';
import '../../providers/user_provider.dart';
import '../../models/user_profile.dart'; // Import UserProfile
class PadSettingsDialog extends ConsumerStatefulWidget {
const PadSettingsDialog({super.key});
@@ -16,12 +15,12 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
bool _isTrackingEnabled = false;
int _typicalFlow = 2; // Mediumish
int _padAbsorbency = 3; // Regular
// Inventory State
int _padInventoryCount = 0;
int _lowInventoryThreshold = 5;
bool _isAutoInventoryEnabled = true;
final TextEditingController _brandController = TextEditingController();
@override
@@ -32,12 +31,12 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
_isTrackingEnabled = user.isPadTrackingEnabled;
_typicalFlow = user.typicalFlowIntensity ?? 2;
_padAbsorbency = user.padAbsorbency ?? 3;
// Init Inventory
_padInventoryCount = user.padInventoryCount;
_lowInventoryThreshold = user.lowInventoryThreshold;
_isAutoInventoryEnabled = user.isAutoInventoryEnabled;
_brandController.text = user.padBrand ?? '';
}
}
@@ -58,12 +57,18 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
padInventoryCount: _padInventoryCount,
lowInventoryThreshold: _lowInventoryThreshold,
isAutoInventoryEnabled: _isAutoInventoryEnabled,
lastInventoryUpdate: (_padInventoryCount != (user.padInventoryCount)) ? DateTime.now() : user.lastInventoryUpdate,
padBrand: _brandController.text.trim().isEmpty ? null : _brandController.text.trim(),
lastInventoryUpdate: (_padInventoryCount != (user.padInventoryCount))
? DateTime.now()
: user.lastInventoryUpdate,
padBrand: _brandController.text.trim().isEmpty
? null
: _brandController.text.trim(),
);
await ref.read(userProfileProvider.notifier).updateProfile(updatedProfile);
await ref
.read(userProfileProvider.notifier)
.updateProfile(updatedProfile);
if (mounted) {
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
@@ -92,7 +97,7 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
),
),
const SizedBox(height: 24),
// Toggle
Row(
children: [
@@ -108,14 +113,14 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
Switch(
value: _isTrackingEnabled,
onChanged: (val) => setState(() => _isTrackingEnabled = val),
activeColor: AppColors.menstrualPhase,
activeThumbColor: AppColors.menstrualPhase,
),
],
),
if (_isTrackingEnabled) ...[
const Divider(height: 32),
// Typical Flow
Text(
'Typical Flow Intensity',
@@ -128,34 +133,40 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
const SizedBox(height: 8),
Row(
children: [
Text('Light', style: GoogleFonts.outfit(fontSize: 12, color: AppColors.warmGray)),
Text('Light',
style: GoogleFonts.outfit(
fontSize: 12, color: AppColors.warmGray)),
Expanded(
child: Slider(
value: _typicalFlow.toDouble(),
min: 1,
max: 5,
divisions: 4,
activeColor: AppColors.menstrualPhase,
onChanged: (val) => setState(() => _typicalFlow = val.round()),
activeColor: AppColors
.menstrualPhase, // Slider still uses activeColor in many versions, check specifically.
// If it's SwitchListTile, it's activeColor, Slider is activeColor.
// Actually, let's keep it as is if it's not deprecated for Slider.
onChanged: (val) =>
setState(() => _typicalFlow = val.round()),
),
),
Text('Heavy', style: GoogleFonts.outfit(fontSize: 12, color: AppColors.warmGray)),
Text('Heavy',
style: GoogleFonts.outfit(
fontSize: 12, color: AppColors.warmGray)),
],
),
Center(
child: Text(
'$_typicalFlow/5',
style: GoogleFonts.outfit(
fontWeight: FontWeight.bold,
color: AppColors.menstrualPhase
)
),
child: Text('$_typicalFlow/5',
style: GoogleFonts.outfit(
fontWeight: FontWeight.bold,
color: AppColors.menstrualPhase)),
),
const SizedBox(height: 20),
// Pad Absorbency
Text(
Text(
'Pad Absorbency/Capacity',
style: GoogleFonts.outfit(
fontSize: 14,
@@ -166,11 +177,15 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
const SizedBox(height: 4),
Text(
'Regular(3), Super(4), Overnight(5)',
style: GoogleFonts.outfit(fontSize: 12, color: AppColors.warmGray.withOpacity(0.8)),
style: GoogleFonts.outfit(
fontSize: 12,
color: AppColors.warmGray.withValues(alpha: 0.8)),
),
Row(
children: [
Text('Low', style: GoogleFonts.outfit(fontSize: 12, color: AppColors.warmGray)),
Text('Low',
style: GoogleFonts.outfit(
fontSize: 12, color: AppColors.warmGray)),
Expanded(
child: Slider(
value: _padAbsorbency.toDouble(),
@@ -178,24 +193,24 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
max: 5,
divisions: 4,
activeColor: AppColors.menstrualPhase,
onChanged: (val) => setState(() => _padAbsorbency = val.round()),
onChanged: (val) =>
setState(() => _padAbsorbency = val.round()),
),
),
Text('High', style: GoogleFonts.outfit(fontSize: 12, color: AppColors.warmGray)),
Text('High',
style: GoogleFonts.outfit(
fontSize: 12, color: AppColors.warmGray)),
],
),
Center(
child: Text(
'$_padAbsorbency/5',
style: GoogleFonts.outfit(
fontWeight: FontWeight.bold,
color: AppColors.menstrualPhase
)
),
child: Text('$_padAbsorbency/5',
style: GoogleFonts.outfit(
fontWeight: FontWeight.bold,
color: AppColors.menstrualPhase)),
),
const SizedBox(height: 20),
// Brand
Text(
'Preferred Brand',
@@ -211,12 +226,13 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
decoration: InputDecoration(
hintText: 'e.g., Always Infinity, Cora, Period Undies...',
filled: true,
fillColor: AppColors.warmCream.withOpacity(0.5),
fillColor: AppColors.warmCream.withValues(alpha: 0.5),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
),
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
contentPadding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
),
),
@@ -227,9 +243,10 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
// Inventory Management Header
Row(
children: [
Icon(Icons.inventory_2_outlined, size: 20, color: AppColors.navyBlue),
const SizedBox(width: 8),
Text(
const Icon(Icons.inventory_2_outlined,
size: 20, color: AppColors.navyBlue),
const SizedBox(width: 8),
Text(
'Inventory Tracking',
style: GoogleFonts.outfit(
fontSize: 16,
@@ -250,38 +267,45 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
children: [
Text(
'Current Stock',
style: GoogleFonts.outfit(fontWeight: FontWeight.w500, color: AppColors.warmGray),
style: GoogleFonts.outfit(
fontWeight: FontWeight.w500,
color: AppColors.warmGray),
),
Text(
'Pad Inventory',
style: GoogleFonts.outfit(fontSize: 12, color: AppColors.warmGray.withOpacity(0.8)),
style: GoogleFonts.outfit(
fontSize: 12,
color: AppColors.warmGray.withValues(alpha: 0.8)),
),
],
),
),
Container(
decoration: BoxDecoration(
color: AppColors.warmCream.withOpacity(0.5),
color: AppColors.warmCream.withValues(alpha: 0.5),
borderRadius: BorderRadius.circular(12),
),
child: Row(
children: [
IconButton(
icon: const Icon(Icons.remove, size: 20, color: AppColors.navyBlue),
icon: const Icon(Icons.remove,
size: 20, color: AppColors.navyBlue),
onPressed: () {
if (_padInventoryCount > 0) setState(() => _padInventoryCount--);
if (_padInventoryCount > 0) {
setState(() => _padInventoryCount--);
}
},
),
Text(
'$_padInventoryCount',
style: GoogleFonts.outfit(
fontSize: 18,
fontWeight: FontWeight.bold,
color: AppColors.navyBlue
),
fontSize: 18,
fontWeight: FontWeight.bold,
color: AppColors.navyBlue),
),
IconButton(
icon: const Icon(Icons.add, size: 20, color: AppColors.navyBlue),
icon: const Icon(Icons.add,
size: 20, color: AppColors.navyBlue),
onPressed: () => setState(() => _padInventoryCount++),
),
],
@@ -289,7 +313,7 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
),
],
),
const SizedBox(height: 16),
// Low Stock Threshold
@@ -301,11 +325,15 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
children: [
Text(
'Low Stock Alert',
style: GoogleFonts.outfit(fontWeight: FontWeight.w500, color: AppColors.warmGray),
style: GoogleFonts.outfit(
fontWeight: FontWeight.w500,
color: AppColors.warmGray),
),
Text(
'Warn when below $_lowInventoryThreshold',
style: GoogleFonts.outfit(fontSize: 12, color: AppColors.warmGray.withOpacity(0.8)),
style: GoogleFonts.outfit(
fontSize: 12,
color: AppColors.warmGray.withValues(alpha: 0.8)),
),
],
),
@@ -318,7 +346,8 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
max: 20,
divisions: 19,
activeColor: AppColors.rose,
onChanged: (val) => setState(() => _lowInventoryThreshold = val.round()),
onChanged: (val) =>
setState(() => _lowInventoryThreshold = val.round()),
),
),
],
@@ -326,23 +355,26 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
// Auto Deduct Toggle
SwitchListTile(
contentPadding: EdgeInsets.zero,
title: Text(
'Auto-deduct on Log',
style: GoogleFonts.outfit(fontWeight: FontWeight.w500, color: AppColors.charcoal),
),
subtitle: Text(
'Reduce count when you log a pad',
style: GoogleFonts.outfit(fontSize: 12, color: AppColors.warmGray),
),
value: _isAutoInventoryEnabled,
onChanged: (val) => setState(() => _isAutoInventoryEnabled = val),
activeColor: AppColors.menstrualPhase,
contentPadding: EdgeInsets.zero,
title: Text(
'Auto-deduct on Log',
style: GoogleFonts.outfit(
fontWeight: FontWeight.w500, color: AppColors.charcoal),
),
subtitle: Text(
'Reduce count when you log a pad',
style: GoogleFonts.outfit(
fontSize: 12, color: AppColors.warmGray),
),
value: _isAutoInventoryEnabled,
onChanged: (val) =>
setState(() => _isAutoInventoryEnabled = val),
activeThumbColor: AppColors.menstrualPhase,
),
],
const SizedBox(height: 32),
// Buttons
Row(
mainAxisAlignment: MainAxisAlignment.end,
@@ -360,7 +392,8 @@ class _PadSettingsDialogState extends ConsumerState<PadSettingsDialog> {
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.navyBlue,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
),
child: const Text('Save'),
),