Flutter dropdown button selected value position


This Content is from Stack Overflow. Question asked by Gryva

How can I make the selected dropdown item appear first in the list when its opened?
I’m using GetX for state,

is this the proper way of doing it anyway?

This is the code:

var dropdownvalue = 'Default'.obs;
  var items = [
  RxInt selectedIndex = 0.obs;

Obx(() => DropdownButton(
                    value: dropdownvalue.value,
                    items: items.map((String items) {
                      return DropdownMenuItem(
                        value: items,
                        child: Text(items),
                    onChanged: (value) {
                      dropdownvalue.value = value.toString();

This is how it looks now:

enter image description here

The list should stay in one place when its opened, and values should change places.


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?