diff --git a/android/.gradle/8.11.1/checksums/checksums.lock b/android/.gradle/8.11.1/checksums/checksums.lock index 0a66ca0..df9313d 100644 Binary files a/android/.gradle/8.11.1/checksums/checksums.lock and b/android/.gradle/8.11.1/checksums/checksums.lock differ diff --git a/android/.gradle/8.11.1/checksums/md5-checksums.bin b/android/.gradle/8.11.1/checksums/md5-checksums.bin index 8223bc4..6cf0b47 100644 Binary files a/android/.gradle/8.11.1/checksums/md5-checksums.bin and b/android/.gradle/8.11.1/checksums/md5-checksums.bin differ diff --git a/android/.gradle/8.11.1/checksums/sha1-checksums.bin b/android/.gradle/8.11.1/checksums/sha1-checksums.bin index 8402e6f..3f58629 100644 Binary files a/android/.gradle/8.11.1/checksums/sha1-checksums.bin and b/android/.gradle/8.11.1/checksums/sha1-checksums.bin differ diff --git a/android/.gradle/8.11.1/executionHistory/executionHistory.bin b/android/.gradle/8.11.1/executionHistory/executionHistory.bin index b29e0c0..f27630c 100644 Binary files a/android/.gradle/8.11.1/executionHistory/executionHistory.bin and b/android/.gradle/8.11.1/executionHistory/executionHistory.bin differ diff --git a/android/.gradle/8.11.1/executionHistory/executionHistory.lock b/android/.gradle/8.11.1/executionHistory/executionHistory.lock index 8058015..33ce044 100644 Binary files a/android/.gradle/8.11.1/executionHistory/executionHistory.lock and b/android/.gradle/8.11.1/executionHistory/executionHistory.lock differ diff --git a/android/.gradle/8.11.1/fileHashes/fileHashes.bin b/android/.gradle/8.11.1/fileHashes/fileHashes.bin index 6b0e6fe..37b4bb1 100644 Binary files a/android/.gradle/8.11.1/fileHashes/fileHashes.bin and b/android/.gradle/8.11.1/fileHashes/fileHashes.bin differ diff --git a/android/.gradle/8.11.1/fileHashes/fileHashes.lock b/android/.gradle/8.11.1/fileHashes/fileHashes.lock index dd044d8..742ac25 100644 Binary files a/android/.gradle/8.11.1/fileHashes/fileHashes.lock and b/android/.gradle/8.11.1/fileHashes/fileHashes.lock differ diff --git a/android/.gradle/8.11.1/fileHashes/resourceHashesCache.bin b/android/.gradle/8.11.1/fileHashes/resourceHashesCache.bin index 2f2610e..6b85cdb 100644 Binary files a/android/.gradle/8.11.1/fileHashes/resourceHashesCache.bin and b/android/.gradle/8.11.1/fileHashes/resourceHashesCache.bin differ diff --git a/android/.gradle/8.12/checksums/checksums.lock b/android/.gradle/8.12/checksums/checksums.lock new file mode 100644 index 0000000..746463b Binary files /dev/null and b/android/.gradle/8.12/checksums/checksums.lock differ diff --git a/android/.gradle/8.12/checksums/md5-checksums.bin b/android/.gradle/8.12/checksums/md5-checksums.bin new file mode 100644 index 0000000..12f9f93 Binary files /dev/null and b/android/.gradle/8.12/checksums/md5-checksums.bin differ diff --git a/android/.gradle/8.12/checksums/sha1-checksums.bin b/android/.gradle/8.12/checksums/sha1-checksums.bin new file mode 100644 index 0000000..6f4d3ea Binary files /dev/null and b/android/.gradle/8.12/checksums/sha1-checksums.bin differ diff --git a/android/.gradle/8.12/executionHistory/executionHistory.bin b/android/.gradle/8.12/executionHistory/executionHistory.bin new file mode 100644 index 0000000..a57e63d Binary files /dev/null and b/android/.gradle/8.12/executionHistory/executionHistory.bin differ diff --git a/android/.gradle/8.12/executionHistory/executionHistory.lock b/android/.gradle/8.12/executionHistory/executionHistory.lock new file mode 100644 index 0000000..b8b0960 Binary files /dev/null and b/android/.gradle/8.12/executionHistory/executionHistory.lock differ diff --git a/android/.gradle/8.12/fileChanges/last-build.bin b/android/.gradle/8.12/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/android/.gradle/8.12/fileChanges/last-build.bin differ diff --git a/android/.gradle/8.12/fileHashes/fileHashes.bin b/android/.gradle/8.12/fileHashes/fileHashes.bin new file mode 100644 index 0000000..ad27d30 Binary files /dev/null and b/android/.gradle/8.12/fileHashes/fileHashes.bin differ diff --git a/android/.gradle/8.12/fileHashes/fileHashes.lock b/android/.gradle/8.12/fileHashes/fileHashes.lock new file mode 100644 index 0000000..c998962 Binary files /dev/null and b/android/.gradle/8.12/fileHashes/fileHashes.lock differ diff --git a/android/.gradle/8.12/fileHashes/resourceHashesCache.bin b/android/.gradle/8.12/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..eb383b0 Binary files /dev/null and b/android/.gradle/8.12/fileHashes/resourceHashesCache.bin differ diff --git a/android/.gradle/8.12/gc.properties b/android/.gradle/8.12/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 4ba22f4..b0dac7d 100644 Binary files a/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/android/.gradle/buildOutputCleanup/outputFiles.bin b/android/.gradle/buildOutputCleanup/outputFiles.bin index f0e5193..4212677 100644 Binary files a/android/.gradle/buildOutputCleanup/outputFiles.bin and b/android/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/android/.gradle/file-system.probe b/android/.gradle/file-system.probe index 8120f5e..c3a9c27 100644 Binary files a/android/.gradle/file-system.probe and b/android/.gradle/file-system.probe differ diff --git a/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java b/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java index 3c5b77b..09c96e2 100644 --- a/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java +++ b/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java @@ -20,6 +20,16 @@ public static void registerWith(@NonNull FlutterEngine flutterEngine) { } catch (Exception e) { Log.e(TAG, "Error registering plugin flutter_plugin_android_lifecycle, io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin", e); } + try { + flutterEngine.getPlugins().add(new com.google_mlkit_barcode_scanning.GoogleMlKitBarcodeScanningPlugin()); + } catch (Exception e) { + Log.e(TAG, "Error registering plugin google_mlkit_barcode_scanning, com.google_mlkit_barcode_scanning.GoogleMlKitBarcodeScanningPlugin", e); + } + try { + flutterEngine.getPlugins().add(new com.google_mlkit_commons.GoogleMlKitCommonsPlugin()); + } catch (Exception e) { + Log.e(TAG, "Error registering plugin google_mlkit_commons, com.google_mlkit_commons.GoogleMlKitCommonsPlugin", e); + } try { flutterEngine.getPlugins().add(new io.flutter.plugins.imagepicker.ImagePickerPlugin()); } catch (Exception e) { diff --git a/android/local.properties b/android/local.properties index c011b02..9680816 100644 --- a/android/local.properties +++ b/android/local.properties @@ -1,4 +1,4 @@ -sdk.dir=C:\\Users\\krcho\\AppData\\Local\\Android\\sdk +sdk.dir=C:\\Users\\ASAA\\AppData\\Local\\Android\\sdk flutter.sdk=C:\\flutter flutter.buildMode=debug flutter.versionName=1.0.0 diff --git a/lib/Dashboard_Screen.dart b/lib/Dashboard_Screen.dart index 2b0a1a0..08a32c9 100644 --- a/lib/Dashboard_Screen.dart +++ b/lib/Dashboard_Screen.dart @@ -1,20 +1,22 @@ import 'package:flutter/material.dart'; import 'Signin_Screen.dart'; -import 'package:mobile_scanner/mobile_scanner.dart' as mobile_scanner; +import 'package:mobile_scanner/mobile_scanner.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; import 'package:permission_handler/permission_handler.dart'; import 'package:image_picker/image_picker.dart'; import 'dart:io'; - +import 'package:google_mlkit_barcode_scanning/google_mlkit_barcode_scanning.dart' as mlkit; +import 'screens/diet_plan_screen.dart'; +import 'screens/help_screen.dart'; +import 'screens/history_screen.dart'; +import 'screens/product_details_screen.dart'; +import 'screens/settings_screen.dart'; import 'screens/diet_plan_screen.dart'; import 'screens/help_screen.dart'; import 'screens/history_screen.dart'; import 'screens/product_details_screen.dart'; import 'screens/settings_screen.dart'; - -import 'package:google_mlkit_barcode_scanning/google_mlkit_barcode_scanning.dart'; - class DashboardScreen extends StatefulWidget { const DashboardScreen({Key? key}) : super(key: key); @@ -29,17 +31,17 @@ class _DashboardScreenState extends State int _selectedIndex = 0; // Scanner state with lifecycle management - mobile_scanner.MobileScannerController? cameraController; + MobileScannerController? cameraController; Map? _productInfo; bool _isLoading = false; bool _isScannerActive = false; bool _isTorchOn = false; + String? _lastScannedBarcode; - + // Image picker and scanner final ImagePicker _imagePicker = ImagePicker(); File? _selectedImage; - final BarcodeScanner _barcodeScanner = BarcodeScanner(); - String? _lastScannedBarcode; + final mlkit.BarcodeScanner _barcodeScanner = mlkit.BarcodeScanner(); // Nutritionix API credentials final String nutritionixAppId = '2f699f85'; @@ -90,10 +92,10 @@ class _DashboardScreenState extends State void _initializeCamera() { if (cameraController != null) return; - cameraController = mobile_scanner.MobileScannerController( - detectionSpeed: mobile_scanner.DetectionSpeed.noDuplicates, - facing: mobile_scanner.CameraFacing.back, - formats: [mobile_scanner.BarcodeFormat.ean13], + cameraController = MobileScannerController( + detectionSpeed: DetectionSpeed.noDuplicates, + facing: CameraFacing.back, + formats: [BarcodeFormat.ean13, BarcodeFormat.upcA, BarcodeFormat.upcE], returnImage: false, torchEnabled: _isTorchOn, ); @@ -113,66 +115,6 @@ class _DashboardScreenState extends State cameraController = null; } - Future _scanImage(File imageFile) async { - if (!mounted) return; - - setState(() { - _isLoading = true; - }); - - try { - final inputImage = InputImage.fromFilePath(imageFile.path); - final List barcodes = await _barcodeScanner.processImage(inputImage); - - if (barcodes.isNotEmpty) { - for (final barcode in barcodes) { - debugPrint('Detected barcode from image: ${barcode.rawValue}'); - if (barcode.rawValue != null && barcode.rawValue!.length == 13) { - setState(() { - _lastScannedBarcode = barcode.rawValue; - }); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Barcode detected: ${barcode.rawValue}'), - duration: const Duration(seconds: 2), - ), - ); - await _fetchNutritionalInfo(barcode.rawValue!); - return; - } - } - _showError('No valid barcode found in image'); - } else { - _showError('No barcode detected in image'); - } - } catch (e) { - debugPrint('Error scanning image: $e'); - _showError('Error scanning image: $e'); - } finally { - setState(() { - _isLoading = false; - }); - } - } - - Future _pickAndScanImage() async { - try { - final XFile? pickedFile = await _imagePicker.pickImage( - source: ImageSource.gallery, - imageQuality: 100, - ); - - if (pickedFile != null) { - setState(() { - _selectedImage = File(pickedFile.path); - }); - await _scanImage(_selectedImage!); - } - } catch (e) { - _showError('Error picking image: $e'); - } - } - Future _startScanner() async { final status = await Permission.camera.request(); if (!mounted) return; @@ -218,10 +160,10 @@ class _DashboardScreenState extends State child: Stack( children: [ if (_isScannerActive && cameraController != null) - mobile_scanner.MobileScanner( + MobileScanner( controller: cameraController!, onDetect: (capture) { - final List barcodes = capture.barcodes; + final List barcodes = capture.barcodes; for (final barcode in barcodes) { debugPrint( 'Detected barcode: ${barcode.rawValue}', @@ -229,17 +171,12 @@ class _DashboardScreenState extends State if (barcode.rawValue != null && barcode.rawValue!.length == 13) { if (!mounted) return; - setState(() { - _lastScannedBarcode = barcode.rawValue; - }); ScaffoldMessenger.of(context).showSnackBar( - - - SnackBar( - content: Text('Barcode detected: ${barcode.rawValue}'), - duration: const Duration(seconds: 2), - - + const SnackBar( + content: Text( + 'Barcode detected! Fetching information...', + ), + duration: Duration(seconds: 1), ), ); Navigator.pop(context); @@ -300,7 +237,7 @@ class _DashboardScreenState extends State } } - // Image selection and scanning method + // Image selection method Future _selectImageFromGallery() async { try { final XFile? image = await _imagePicker.pickImage( @@ -309,21 +246,16 @@ class _DashboardScreenState extends State if (image != null && mounted) { setState(() { _selectedImage = File(image.path); - _isLoading = true; }); - - await _scanImage(_selectedImage!); + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text('Image selected successfully!'))); } } catch (e) { if (mounted) { - ScaffoldMessenger.of(context) - .showSnackBar(SnackBar(content: Text('Error selecting image: $e'))); - } - } finally { - if (mounted) { - setState(() { - _isLoading = false; - }); + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text('Error selecting image: $e'))); } } } @@ -339,15 +271,13 @@ class _DashboardScreenState extends State try { debugPrint('Fetching info for barcode: $barcode'); // Try with Nutritionix API - final response = await http.post( - Uri.parse('https://trackapi.nutritionix.com/v2/natural/nutrients'), + final response = await http.get( + Uri.parse('https://trackapi.nutritionix.com/v2/search/item?upc=$barcode'), headers: { 'x-app-id': nutritionixAppId, 'x-app-key': nutritionixApiKey, 'Accept': 'application/json', - 'Content-Type': 'application/json', }, - body: json.encode({'query': 'KitKat chocolate bar', 'locale': 'en_US'}), ); if (!mounted) return; @@ -366,6 +296,11 @@ class _DashboardScreenState extends State 'brand': foodData['brand_name'] ?? 'Unknown Brand', 'serving_size': '${foodData['serving_qty']} ${foodData['serving_unit']}', + 'photo': { + 'thumb': foodData['photo']?['thumb'], + 'highres': foodData['photo']?['highres'], + 'is_user_uploaded': foodData['photo']?['is_user_uploaded'] ?? false, + }, 'nutriments': { 'energy-kcal_100g': foodData['nf_calories'], 'proteins_100g': foodData['nf_protein'], @@ -490,7 +425,6 @@ class _DashboardScreenState extends State backgroundColor: Colors.transparent, builder: (BuildContext context) { return Container( - height: MediaQuery.of(context).size.height * 0.9, decoration: const BoxDecoration( color: Color(0xFF2E8B57), @@ -501,7 +435,7 @@ class _DashboardScreenState extends State ), child: Column( children: [ - // Header + // Header with back button Padding( padding: const EdgeInsets.all(20.0), child: Row( @@ -509,112 +443,99 @@ class _DashboardScreenState extends State IconButton( onPressed: () => Navigator.of(context).pop(), icon: const Icon(Icons.arrow_back, color: Colors.white), - - padding: const EdgeInsets.all(20.0), - height: MediaQuery.of(context).size.height * 0.8, - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - productName, - style: Theme.of(context).textTheme.headlineSmall, - ), - if (brand.isNotEmpty) - Text( - brand, - style: Theme.of( - context, - ).textTheme.titleMedium?.copyWith(color: Colors.grey[600]), - ), - const SizedBox(height: 20), - if (servingSize.isNotEmpty) - Container( - padding: const EdgeInsets.all(8), - decoration: BoxDecoration( - color: Colors.grey[200], - borderRadius: BorderRadius.circular(8), - ), - const Spacer(), + Expanded( + child: Text( + productName, + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + textAlign: TextAlign.center, + ), + ), IconButton( onPressed: () {}, - icon: const Icon(Icons.search, color: Colors.white), + icon: const Icon(Icons.share, color: Colors.white), ), ], ), - ), - - - const SizedBox(height: 10), - _buildNutrientRow('Calories', nutriments['energy-kcal_100g']), - _buildNutrientRow('Protein', nutriments['proteins_100g']), - _buildNutrientRow( - 'Total Carbohydrates', - nutriments['carbohydrates_100g'], - ), - _buildNutrientRow('Total Fat', nutriments['fat_100g']), - _buildNutrientRow('Dietary Fiber', nutriments['fiber_100g']), - _buildNutrientRow('Sugars', nutriments['sugars_100g']), - _buildNutrientRow('Sodium', nutriments['sodium_100g']), - _buildNutrientRow( - 'Cholesterol', - nutriments['cholesterol_100g'], - ), - if (ingredients.isNotEmpty) ...[ - const SizedBox(height: 20), - const Text( - 'Ingredients', - style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), - ), - const SizedBox(height: 10), - Text(ingredients, style: const TextStyle(fontSize: 14)), - ], - if (allergens.isNotEmpty) ...[ - const SizedBox(height: 20), - const Text( - 'Allergen Warning', - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - color: Colors.red, - + // Content Container + Expanded( + child: Container( + decoration: const BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(25), + topRight: Radius.circular(25), ), ), child: SingleChildScrollView( padding: const EdgeInsets.all(25.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + // Product Image + if (_productInfo!['photo']?['thumb'] != null) ...[ + Center( + child: Container( + width: 200, + height: 200, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(15), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.2), + spreadRadius: 2, + blurRadius: 10, + offset: const Offset(0, 3), + ), + ], + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(15), + child: Image.network( + _productInfo!['photo']['highres'] ?? _productInfo!['photo']['thumb'], + fit: BoxFit.cover, + loadingBuilder: (context, child, loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: CircularProgressIndicator( + value: loadingProgress.expectedTotalBytes != null + ? loadingProgress.cumulativeBytesLoaded / + loadingProgress.expectedTotalBytes! + : null, + valueColor: const AlwaysStoppedAnimation(Color(0xFF2E8B57)), + ), + ); + }, + errorBuilder: (context, error, stackTrace) { + return Container( + color: Colors.grey[100], + child: const Center( + child: Icon( + Icons.image_not_supported, + size: 40, + color: Colors.grey, + ), + ), + ); + }, + ), + ), + ), + ), + const SizedBox(height: 20), + ], // Food Image and Info Center( child: Column( children: [ - Container( - width: 200, - height: 200, - decoration: BoxDecoration( - color: Colors.black87, - borderRadius: BorderRadius.circular(100), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.3), - spreadRadius: 0, - blurRadius: 20, - offset: const Offset(0, 10), - ), - ], - ), - child: const Icon( - Icons.restaurant_menu, - color: Colors.white, - size: 80, - ), - ), + const SizedBox(height: 25), Text( productName, @@ -814,19 +735,6 @@ class _DashboardScreenState extends State const SizedBox(height: 20), ], -======= - children: allergens - .map( - (allergen) => Padding( - padding: const EdgeInsets.symmetric(vertical: 2), - child: Text( - '• $allergen', - style: const TextStyle(color: Colors.red), - ), - ), - ) - .toList(), - ), ), ), @@ -838,7 +746,6 @@ class _DashboardScreenState extends State ); } - Widget _buildNutritionCard(String value, String label) { return Container( padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 10), @@ -866,28 +773,6 @@ class _DashboardScreenState extends State ), ), const SizedBox(height: 5), - - Widget _buildNutrientRow(String label, dynamic value) { - String displayValue; - if (value == null) { - displayValue = 'N/A'; - } else { - String unit = 'g'; - if (label == 'Calories') { - unit = 'kcal'; - } else if (label == 'Sodium' || label == 'Cholesterol') { - unit = 'mg'; - } - displayValue = '${value.toStringAsFixed(1)}$unit'; - } - - return Padding( - padding: const EdgeInsets.symmetric(vertical: 4.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(label, style: const TextStyle(fontSize: 16)), - Text( label, style: TextStyle( @@ -905,69 +790,7 @@ class _DashboardScreenState extends State return SingleChildScrollView( child: Column( children: [ - // Header Section - - // Welcome Header - const Text( - 'Welcome to MindSprint! 👋', - style: TextStyle( - fontSize: 24, - fontWeight: FontWeight.bold, - color: Color(0xFF2D3748), - ), - ), - const SizedBox(height: 10), - const Text( - 'Ready to scan and eat healthy?', - style: TextStyle(fontSize: 16, color: Color(0xFF718096)), - ), - const SizedBox(height: 20), - - // Last Scanned Barcode - if (_lastScannedBarcode != null) Container( - width: double.infinity, - padding: const EdgeInsets.all(15), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(15), - border: Border.all(color: const Color(0xFFE2E8F0)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.1), - spreadRadius: 0, - blurRadius: 10, - offset: const Offset(0, 4), - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text( - 'Last Scanned Barcode:', - style: TextStyle( - fontSize: 14, - color: Color(0xFF718096), - fontWeight: FontWeight.w500, - ), - ), - const SizedBox(height: 8), - Text( - _lastScannedBarcode!, - style: const TextStyle( - fontSize: 18, - color: Color(0xFF2D3748), - fontWeight: FontWeight.bold, - ), - ), - ], - ), - ), - const SizedBox(height: 30), - - // Main Scan Button - Container( padding: const EdgeInsets.fromLTRB(20, 50, 20, 30), decoration: const BoxDecoration( @@ -2612,7 +2435,7 @@ class _DashboardScreenState extends State final TextEditingController diseaseController = TextEditingController(); final TextEditingController descriptionController = TextEditingController(); - String? selectedGender = SigninScreen.userData['gender']; + String selectedGender = SigninScreen.userData['user_gender'] ?? 'Male'; // Populate controllers with existing data nameController.text = SigninScreen.userData['user_name'] ?? ''; @@ -2662,17 +2485,6 @@ class _DashboardScreenState extends State ), ), const SizedBox(height: 12), - TextField( - controller: TextEditingController( - text: selectedGender ?? "Not set", - ), - decoration: const InputDecoration( - labelText: 'Gender', - border: OutlineInputBorder(), - ), - enabled: false, - ), - const SizedBox(height: 12), TextField( controller: petNameController, decoration: const InputDecoration( @@ -2737,9 +2549,29 @@ class _DashboardScreenState extends State keyboardType: TextInputType.number, ), const SizedBox(height: 12), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8.0), - // Removed duplicate gender display from Health Information section + StatefulBuilder( + builder: (context, setStateLocal) { + return DropdownButtonFormField( + decoration: const InputDecoration( + labelText: 'Gender', + border: OutlineInputBorder(), + ), + value: selectedGender, + items: ['Male', 'Female', 'Other'].map(( + String value, + ) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + onChanged: (String? newValue) { + setStateLocal(() { + selectedGender = newValue!; + }); + }, + ); + }, ), const SizedBox(height: 12), TextField( @@ -2782,7 +2614,7 @@ class _DashboardScreenState extends State SigninScreen.userData['user_age'] = ageController.text; SigninScreen.userData['user_height'] = heightController.text; SigninScreen.userData['user_weight'] = weightController.text; - SigninScreen.userData['user_gender'] = selectedGender ?? ''; + SigninScreen.userData['user_gender'] = selectedGender; SigninScreen.userData['user_allergic'] = allergicController.text; SigninScreen.userData['user_disease'] = diseaseController.text; diff --git a/lib/Detail_Screen.dart b/lib/Detail_Screen.dart index 24137da..18fdd70 100644 --- a/lib/Detail_Screen.dart +++ b/lib/Detail_Screen.dart @@ -3,9 +3,7 @@ import 'Signin_Screen.dart'; import 'Login_Screen.dart'; class DetailScreen extends StatefulWidget { - - const DetailScreen({Key? key}) : super(key: key); - + DetailScreen({Key? key}) : super(key: key); @override State createState() => _DetailScreenState(); @@ -18,9 +16,7 @@ class _DetailScreenState extends State { final TextEditingController diseaseController = TextEditingController(); final TextEditingController descriptionController = TextEditingController(); - String? _selectedGender; - final List _genderOptions = ['Male', 'Female', 'Other']; - + String _selectedGender = 'Male'; Future _saveDetailData() async { // Add additional details to the existing user data @@ -29,7 +25,6 @@ class _DetailScreenState extends State { SigninScreen.userData['user_allergic'] = allergicController.text; SigninScreen.userData['user_disease'] = diseaseController.text; SigninScreen.userData['user_description'] = descriptionController.text; - SigninScreen.userData['user_gender'] = _selectedGender; } @@ -70,8 +65,6 @@ class _DetailScreenState extends State { ), ), ); - - } @override @@ -163,7 +156,6 @@ class _DetailScreenState extends State { ), ], ), - const SizedBox(height: 16), Row( children: [ @@ -215,39 +207,6 @@ class _DetailScreenState extends State { ], ), ], - - ), - ), - const SizedBox(height: 20), - - // Additional details form - // ...existing code... - // ...existing code... - TextField( - controller: heightController, - decoration: const InputDecoration( - labelText: 'Height (cm)', - border: OutlineInputBorder(), - ), - keyboardType: TextInputType.number, - ), - const SizedBox(height: 16), - TextField( - controller: weightController, - decoration: const InputDecoration( - labelText: 'Weight (kg)', - border: OutlineInputBorder(), - ), - keyboardType: TextInputType.number, - ), - const SizedBox(height: 16), - TextField( - controller: allergicController, - decoration: const InputDecoration( - labelText: 'Allergic to', - border: OutlineInputBorder(), - ), - ), ), const SizedBox(height: 20),