I was trying to see how to use two State providers in Riverpod and one of them depends on the other. Two approaches are given here.

  • The example fetches X number of jokes from an API, where X is one state and is incremented whenever floating action button is pressed.
  • The other state is the jokes.

Whenever the counter changes, those many number of jokes are fetched from the API and they become the new state. A ListView is rendered using the latest list of jokes.

Sample #1

Sample #2