Comments (1)
Upgrade to latest version. Here's an example of how to do it:
final dropdownKey = GlobalKey<DropdownButton2State>();
final List<String> items = [
'Item1',
'Item2',
'Item3',
'Item4',
];
String? selectedValue;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: () {
dropdownKey.currentState!.callTap();
},
child: Container(
height: 100,
width: 100,
color: Colors.red,
),
),
DropdownButtonHideUnderline(
child: DropdownButton2(
key: dropdownKey,
hint: Text(
'Select Item',
style: TextStyle(
fontSize: 14,
color: Theme.of(context).hintColor,
),
),
items: items
.map((item) => DropdownMenuItem<String>(
value: item,
child: Text(
item,
style: const TextStyle(
fontSize: 14,
),
),
))
.toList(),
value: selectedValue,
onChanged: (value) {
setState(() {
selectedValue = value as String;
});
},
buttonHeight: 40,
buttonWidth: 140,
itemHeight: 40,
),
),
],
),
),
);
}
from dropdown_button2.
Related Issues (20)
- Button width is not responsive to hint's width HOT 4
- Update an Open Dropdown Menu HOT 8
- Align DropDown to end of the button HOT 1
- [QUESTION] Dropdown icon at the same level as the standard TextFormField suffixIcon
- I am using dropdown searchable but searchable is list is come from network call HOT 22
- Keyboard covering searchable dropdown
- [Bug] offset dy doesn't work for some cases HOT 2
- [Request] Pinned items inside when they out of their parent constraints (X axis) HOT 8
- Height is misaligned compared to standard form fields HOT 4
- clampDouble is not defined function error.
- Could you please remove the splash effect of button pressing? HOT 4
- searchMatchFn doesn't get called HOT 1
- searchMatchFn not working in release mode of app HOT 2
- QUESTION: use value pair for items HOT 2
- When customButton is not empty, how to make the width of each DropdownMenuItem subject to the maximum width in items? HOT 1
- Issue: The named parameter 'searchController' isn't defined HOT 2
- Update items in searchMatchFn without tap dropdown again to show the menu items already updated HOT 2
- Rebuilds when rect has changed error HOT 2
- Clear Button HOT 7
- Empty value HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dropdown_button2.