Creating a separate controller allows for better separation of concerns in your code. By having a dedicated controller class, you can encapsulate the logic related to handling specific functionalities or operations, such as form submissions or API calls. This helps in keeping your notifier classes focused on managing state while delegating the business logic to…
Category: Riverpod
Riverpod 2.0 Counter App
Here is the Riverpod 2.0 Counter app example. Here we covered how to do both increment and decrement. We have done it using two floating action buttons. Let’s see the Riverpod 2.0 provider both for increment and decrement. Here we used Riverpod code generation tool to create or generate Riverpod provider. Here we actually created…
Is Riverpod overrated? Is it difficult?
Yes, it’s overrated and difficult for beginners. Now, I am not saying this because I love other state management package or hate Riverpod. It causes problem and impossible to keep track of the error once you use Notifier Provider and AsyncNotifier Provider together. Riverpod does come with it’s benefit. Like AsyncLoading, AsyncData, AsyncValue. These are…
Flutter Riverpod and Dart only
I’ve seen many articles explaining how to use Riverpod in Flutter, but I haven’t found any that explain how to use Riverpod in Dart only, so I’ll write one. Preparation for provider automatic generation How to create a provider using riverpod_annotation Generating a Provider for String manipulation Generating a Provider for bool toggling Read Provider…
Riverpod Providers or Controllers Folder
Now this seems very confusing when it comes to Riverpod. How we separate the business logic from the UI? Well, I’d consider Riverpod or any state management as part of the controller layer in terms of managing app logic and state, because it does what “controllers” are meant to do, pass information between the views…
The following StackOverflowError was thrown building dirty, dependencies: UncontrolledProviderScope
The above error you get in general if you use Riverpod. It’s a widget to provided by Riverpod to prevent unnecessary rebuild of widget for performance optimization. In the context of Riverpod, “dirty” is often used to describe a state that has changed and needs to be updated or rebuilt. The UncontrolledProviderScope is a widget…
Do not use BuildContext across async gaps
You may see this if you BLoC or Riverpod or just context passing if you try to manage the states of your app. Actually it’s try to say that, you are using context in your function and you are using in between await keyword. See the last line, there’s wiggly line. If you hover over…
Riverpod copyWith method
First of all , can we really use copyWith() method if we use Riverpod?. Yes, we can. Definitely we can. CopyWith() we use to create immutable objects. It means these objects are not editable. Actually copyWith() is independent of any state management package. It’s exactly the same way if you use it with BLoC. Typically…
Riverpod Safe Loading
Here in this article we see how to show loading data icon with properly. We would be using StateNotifier, StateNotifierProvider with AutoDispose. We would also be using future type for state management. Since we are going to simulate data loading from the server, we would need to be dealing with success and failure status. We…
Riverpod Listen and Listener
Flutter Riverpod Listener plays an important role when it comes to detecting state that are available. It’s more like BLocConsumer listener. Based on this listener object we will be able to trigger new routes or screen pop or push. This could be use for showing snackBar. Riverpod Listener stores the earlier states. Of course, It’s…