3 difficulties when I switched my state management from BloC to Riverpod in Flutter

Alper Efe Şahin
CodeX
Published in
3 min readJun 12, 2022

Hello everyone. In this Medium article, I’m gonna talk about 3 difficulties when I switched my state management from BloC to Riverpod.

First things first, I need to say I develop applications for approximately 2 years in the Flutter section. Sometimes I write articles for applications that are useful for people who want to use already built applications like phone number sign-in or normal sign-in, maybe sometimes UI applications (e-commerce, podcast, etc.). When I developed these applications, and also for 2 years, I used BloC/Cubit state management solutions for the applications. It was a great experience for me. Recently, using Riverpod’s own documentation, I switched my state management solution. In this article, I will tell you what did my expectations, and what did I do.

1. Lots of Provider types

Actually, before the bloc, I wanted to use Providers for the state management, but I could not, since there are lots of Providers, such as Provider, FutureProvider, StreamProvider, etc. Of course, these are the basics, but before the 2 years, I had no idea about them, or in the other words, I did not know the process, I just built basics apps. When I felt to switch, there is a Riverpod, which is also a provider. My aim was to learn providers first, and after that, I wanted to switch to other sections. So, firstly, since I know the BloC/Cubit strongly, I did not look at the state management process. I just glanced at how can I use providers, what is the syntax for providers, how can I reach my variable, when I need to use Provider, FutureProvider, etc. All of them are explained in the official Riverpod documentation, so I looked at the official website (riverpod.dev). After I got a general idea, it was time to use the power of the Riverpod for me.

2. Different syntaxes

In Riverpod, there are different text types, both when calling the functions, and when using the states. In bloc, we have to use context to reach BloC or Cubit, but in the Riverpod, we do have not to reach context, since logic three is outside of the Flutter.

3. Documentation

I told you above, Riverpod has nice documentation. Yes, it is, actually. In my opinion, there is a problem after learning Riverpod. When I started learning BloC, there were lots of examples on BloC’s own page. Also, they have their own tutorial for these projects. But in the Riverpod, there are nice examples without the tutorials. Also when I looked the YouTube, I could not find a nice tutorial for it. So, the documentation is good, but not enough I think. It will be improved I think, since the new developers who start the Riverpod, can feel hard to build some things.

In this article, I talked about my experiences. Using Riverpod, I create applications that are NOT counter app, since there are lots of counter app. I have already built 2 applications which are a to-do app and an API-Search app. Also, when I looked on the internet, I could not find nice resources for the StateNotifier + Riverpod + Freezed + DDD (architecture). So I built them, and right now I am building an application related to the Social App. In the upcoming days, I will also share it. And my plan is, for the 3 tutorials, I will write articles for them via Medium.

That’s all for me. Feel free to ask any questions in the comments section. Also, you can glance at my applications which were created with Riverpod from here.

Thank you for reading, stay tuned!

--

--