flutter getx show dropdown using Provider, Repository, MVC


I am new to Flutter, Any one share your idea to show dropdown using getx, I tried listing with List Builder. but don’t have idea about dropdown using GetX ( MVC, provider, repository).


First declare a variable in your controller

var selectedRole = ‘CONTENT_CREATOR’.obs;

then declare this method

void onSelected(String value) {
selectedRole.value = value;
registrationParam.value.roleType = selectedRole.value;


finally call from your UI code like this

                        padding: const EdgeInsets.only(right: 8, left: 16),
                        child: Obx(
                          () => DropdownButton(
                            underline: SizedBox(),
                            isExpanded: true,
                            hint: Text('Select a role'),
                            value: _regController.selectedRole.value,
                            items: [
                                  value: "CONTENT_CREATOR",
                                  child: Text("Content Creator")),
                                  value: "PR", child: Text("PR Agency")),
                                  value: "JOURNALIST",
                                  child: Text("Journalist"))
                            onChanged: (val) {

**Your initial value must be from a value of DropdownMenuItem

Answered By – Taqi Tahmid Tanzil

Answer Checked By – Cary Denson (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *