Open MarvinQuevedo opened 2 months ago
This is already applicable.
Starting from version 3.0.0-beta.13
, instead of:
final dropdownKey = GlobalKey<DropdownButton2State>();
@override
Widget build(BuildContext context) {
return Column(
children:[
DropdownButton2<String>(
// Other properties...
key: dropdownKey,
);
// Open the dropdown programmatically, like when another button is pressed:
ElevatedButton(
onTap: () => dropdownKey.currentState!.callTap(),
),
],
);
}
do:
final openDropdownListenable = ValueNotifier<Object?>(null);
@override
Widget build(BuildContext context) {
return Column(
children:[
DropdownButton2<String>(
// Other properties...
openDropdownListenable: openDropdownListenable,
);
// Open the dropdown programmatically, like when another button is pressed:
ElevatedButton(
onTap: () => openDropdownListenable.value = Object(),
),
],
);
}
Hi, If I am not wrong, you can see here that the state class is private, on my PR I make It to public removing the underscore and make public the handleTab method too, the two are private on your current code,,
Hi, If I am not wrong, you can see here that the state class is private, on my PR I make It to public removing the underscore and make public the handleTab method too, the two are private on your current code,,
Yes, that's on purpose.
You don't need to call the callTap
method anymore. just do:
final openDropdownListenable = ValueNotifier<Object?>(null);
@override
Widget build(BuildContext context) {
return Column(
children:[
DropdownButton2<String>(
// Other properties...
openDropdownListenable: openDropdownListenable,
);
// Open the dropdown programmatically, like when another button is pressed:
ElevatedButton(
onTap: () => openDropdownListenable.value = Object(),
),
],
);
}
We need to show the dropdown from a external widget equal to old versions