2

I am using flutter_bloc library to manage the app's state.

I know how to use cubits and repositories to fetch data from API, but the thing is that I don't want to use all of the data that was fetched, in the first state emitted by the cubit. However, other states, I need some of the other data. I don't know where to store the data in the cubit class or the repository?

I have a screen that shows a map with cards about some stores, and there are the driving and walking directions from the user's location to each store's location. I want to fetch the stores' information, the driving directions, and the walking directions all of them when the screen starts, but I want to show only the driving directions when the data is loaded, and there is a button when it's clicked it should show only the walking directions.

How can I achieve that using the bloc and repository, as I want to fetch all the data when the screen starts and emit different state for the driving direction and the walking directions?

Mary
  • 51
  • 3

0 Answers0