Answers for "getx dropdown"

0

getx dropdown

class BookController extends GetxController {

   // It is mandatory initialize with one value from listType
   final selected = "some book type".obs

   void setSelected(String value){
     selected.value = value;
   }

}
Posted by: Guest on October-21-2021
0

getx dropdown

BookController bookcontroller = BookController();
    
    Obx( () => DropdownButton(
                      hint: Text(
                        'Book Type',
                      ),
                      onChanged: (newValue) {
                        bookController.setSelected(newValue);
                      },
                      value: bookController.selected.value,
                      items: bookController.listType.map((selectedType) {
                        return DropdownMenuItem(
                          child: new Text(
                            selectedType,
                          ),
                          value: selectedType,
                        );
                      }).toList(),
                    )
),
Posted by: Guest on October-21-2021

Browse Popular Code Answers by Language