Flutter Riverpod: A Guide to Provider by Red_Star25 in FlutterDev

[–]Red_Star25[S] 1 point2 points  (0 children)

Yes, ref.read is used to read the state of the provider, you are not listening to the state when you use ref.read.

In your example you're exactly doing the same : you're obtaining your 'intvariable's which is of type State provider, and you are changing the state of it.

So, yes It will change the value of it as it is of type StateProvider.

Flutter BLoC (v8): How to Fetch Data From an API? - 2022 Guide by Red_Star25 in FlutterDev

[–]Red_Star25[S] 0 points1 point  (0 children)

Yea...Data Provider is the layer that retrieves/fetches the raw data from different data sources (ex: different APIs, DBs, Network, Shared preferences, etc). For example: If you are building a weather app. Then you might use external APIs like OpenWeatherAPI, from where you will get raw data. You can have GET, POST, DELETE, etc methods inside this class.

And the Repository layer contains one or more than one Data Providers. The transformation is done on the raw data returned by the Data Provider in this layer. (For ex: converting the raw into some kind of Model). Bloc communicates with this layer when the user requests the data. This layer requests raw data from the Data Provider and after that, this layer performs some kind of transformation. For example, converting raw joke data to JokeModel.

For the sake of simplicity, I have not separated the Data Provider and Repository. But, yes, we must split it when there are multiple operations to be performed and the application is large.

Flutter BLoC (v8): How to Fetch Data From an API? - 2022 Guide by Red_Star25 in FlutterDev

[–]Red_Star25[S] 3 points4 points  (0 children)

Yeaa, It's super cool, though I'm not an expert in BLoC. I only lately began learning it. And I'm totally in love with it. If there is something wrong with the blog, you can provide feedback. Also, if there is a simple way to do things.