DropdownButton updating with Provider


When i choose item in the below list, it does not change. If i click the others,then nothing happens.
How can i change this value both firestore and UI ?
I know, i need to update value: constantValue, this code, but how i can do that with provider?

Here, button:

Widget dropdownButton(BuildContext context) {
String constantValue = "League Of Legends";
return DropdownButton(
    value: constantValue,
    onChanged: (newValue) {
      context.read<PostProvider>().postCategory = newValue;
    items: <String>["League Of Legends", "Steam", "Csgo"]
        .map<DropdownMenuItem<String>>((String value) {
      return DropdownMenuItem<String>(
        value: value,
        child: Text(value),


and also provider:

     String _postCategory;

     String get postCategory => _postCategory;

  set postCategory(String value) {
    _postCategory = value;

enter image description here


You need to include something to write FireBase in the code path. Provider doesn’t magically do that for you. However, you can have various providers or widgets wake up on that notify_listeners() call.

Answered By – Randal Schwartz

Answer Checked By – Marie Seifert (FlutterFixes Admin)

Leave a Reply

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