Search code examples
androidflutterflutter-layoutflutter-webriverpod

Flutter Consumer not rebuilding UI using riverpod StateNotifierProvider


Its my 1st time using riverpod and for practice purposes, I'm making to-do app. I'm using StateNotifierProvider and it's not updating the ListViewBuilder but updating the length of items but not showing that item. Please Guide me, Here is the SC of StateNotifier enter image description here

and here is the calling method to call add method here is the SC enter image description here

and here is the UI UPDATING THE NUMBERS OF items but not updating the list. enter image description here


Solution

  • Modify addTask method like this.

    void addTask(String newTask)
    {
      state=[...state,TaskModel(name: newTask)];
    }
    

    For more information check official documentation for StateNotifierProvider here