From 77ea35a43ffe9e579088ba8a70f68ecc0bdde553 Mon Sep 17 00:00:00 2001 From: Gaurav Kumar Date: Fri, 28 Mar 2025 12:01:17 +0530 Subject: [PATCH] drop --- .../Reuseable/reusable_dropdown_field.dart | 74 +++++++++++++++++++ .../lib/commans/widgets/custome_drawer.dart | 1 + .../lib/data/network/network_api_service.dart | 2 +- 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 base_project/lib/Reuseable/reusable_dropdown_field.dart diff --git a/base_project/lib/Reuseable/reusable_dropdown_field.dart b/base_project/lib/Reuseable/reusable_dropdown_field.dart new file mode 100644 index 0000000..dc57686 --- /dev/null +++ b/base_project/lib/Reuseable/reusable_dropdown_field.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; + +class ReusableDropdownField extends StatelessWidget { + final String label; + final List> options; + final String? value; + final String valueField; // ID key (dynamic) + final String uiField; // Name key (dynamic) + final void Function(String?)? onChanged; + final void Function(String?)? onSaved; + + const ReusableDropdownField({ + super.key, + required this.label, + required this.options, + required this.valueField, // Dynamic ID field + required this.uiField, // Dynamic Name field + this.value, + this.onChanged, + this.onSaved, + }); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: DropdownButtonFormField( + decoration: InputDecoration( + labelText: label, + labelStyle: const TextStyle(color: Colors.deepPurple), + contentPadding: + const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: const BorderSide(color: Colors.deepPurple, width: 2), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: const BorderSide(color: Colors.deepPurple, width: 2), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: + const BorderSide(color: Colors.deepPurpleAccent, width: 2), + ), + ), + value: (value != null && value!.isNotEmpty) ? value : null, + items: [ + const DropdownMenuItem( + value: '', + child: Text('Select an option'), + ), + ...options.map>( + (item) => DropdownMenuItem( + value: item[valueField].toString(), + child: Text( + item[uiField].toString(), + style: const TextStyle(fontSize: 16), + ), + ), + ), + ], + onChanged: onChanged, + onSaved: onSaved, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please select a $label'; + } + return null; + }, + ), + ); + } +} diff --git a/base_project/lib/commans/widgets/custome_drawer.dart b/base_project/lib/commans/widgets/custome_drawer.dart index 149e585..73fb148 100644 --- a/base_project/lib/commans/widgets/custome_drawer.dart +++ b/base_project/lib/commans/widgets/custome_drawer.dart @@ -70,6 +70,7 @@ class MyCustomDrawer extends StatelessWidget { ), // NEW MENU + DrawerItem( icon: Icons.logout, color: Colors.red, diff --git a/base_project/lib/data/network/network_api_service.dart b/base_project/lib/data/network/network_api_service.dart index 5def8a7..606eeb0 100644 --- a/base_project/lib/data/network/network_api_service.dart +++ b/base_project/lib/data/network/network_api_service.dart @@ -18,7 +18,7 @@ class NetworkApiService extends BaseNetworkService { try { final token = UserManager().token; - print("token..$token"); + // print("token..$token"); final headers = { 'Authorization': 'Bearer $token',