CustomDropDownButton is a custom dropdown button widget in Flutter designed to work with any type T. It allows you to populate the dropdown items from outside and provides customization options for item display and handling.
- Create a dropdown button with a list of custom items.
- Set an initial value for the dropdown.
- Customizable display string for each item.
- Callback function for when the value of the dropdown changes.
- Title display above the dropdown button. // optional
- Create an instance of CustomDropDownButton:
![Screenshot 2024-03-07 at 9 04 06 AM](https://private-user-images.githubusercontent.com/101984287/310734728-097383c4-3943-4144-9b79-a0e9c7e63bfc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3NDgxMzgsIm5iZiI6MTczOTc0NzgzOCwicGF0aCI6Ii8xMDE5ODQyODcvMzEwNzM0NzI4LTA5NzM4M2M0LTM5NDMtNDE0NC05Yjc5LWEwZTljN2U2M2JmYy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxNlQyMzE3MThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iYmUxYmZmMGY3ZWRkMTEzZDIzN2Q5MWIyM2FiMDM0YWEwMGIyMmZkYzk0MDUxOGM2ZTg0YjNlOTRlZDNmNWQ2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9._NPllMEmm7Mz6qHIlWAc9tTGfURocIZJQ57JaNxxO9Q)
- initialValue: The initial selected value of the dropdown.
- itemList: List of items to populate the dropdown.
- displayString: A function that returns the display string for each item. If not provided, toString() will be used.
- title: Title to display above the dropdown button.
- onChangedValue: Optional callback function that will be called when the dropdown value changes.
- When the onChangedValue callback is provided, it will be called with the selected value whenever the user selects an item from the dropdown.
- Customize the itemList and displayString to fit the specific needs of your application.
Here's an example of how you might use CustomDropDownButton for String Type:
- In this example, the dropdown button will display a list of fruits, with 'Apple' selected initially. When the user selects a different fruit, the onChangedValue callback will update the selectedFruit variable.
Here's an example where we have a Month class with id and value, and we'll pass a list of Month objects to the CustomDropDownButton to create a dropdown of months:
In this Example: * We have a Monthb class with id and value attributes representing the month's unique identifier and name.This README provides an overview of the CustomDropDownButton class and how to use it in your Flutter applications. Customize the parameters and callbacks according to your specific requirements for a flexible and reusable dropdown button.