Here, we will learn how to use Getx and BLoC together for our dummy flutter app. We will use Getx for routing and BLoC for state management. The real magic happens here The above code uses BlocProvider as wrapper for state management. Inside it we inject our bloc (CounterBlocs) and then in the child we…
Go_router Remove Previous Routes
Learn about Go_router how to remove all the previous routes. Here we will learn how to do it using navigator 2.0 Go_router does not provide a direct api to do it. Currently Go router provides the below api Since go router does not provide direct api, we will below code format to do it Instead…
Flutter Back To Previous Screen
We will explore four ways to go back to previous routes. First way we will explore the native way. Flutter AppBar takes IconButton or any widget that takes onPress or onTap event. Inside event set And you are good to go. So the actual code would look like this Second way If you use Getx…
Flutter HydratedCubit A Cubit And BLoC State Management Package
HydratedCubit A specialized Cubit which handles initializing the Cubit state based on the persisted state. This allows state to be persisted across application restarts. With HydratedCubit you can load JSON data and store JSON data locally. Your HydratedCubit class may look like this Since you want to manage storage using HydratedCubit, your Cubit class must…
Flutter Getx Routing Compare With Native Routing
Here I uncovered Get.until Remove screens until satisfying the condition. It’s the same with Navigation.popUntil(). You can use it like Get.until((route) => Get.currentRoute == ‘/home’). Get.off Remove the current screen and add a new screen. It’s the same with Navigation.pushReplacement(). You can use it like Get.off(Second()). Get.offNamed By the Named route, remove the current screen and add a new…
Difference between Get.offNamedUntil() and Get.offAllNamed()
Get.offAllNamed() removes all the previous routes and goes to the new routes. But if you want better control, then you should be using Get.offNamedUntil. By using Get.offNamedUntil() you can control upto which routes to remove from the stack. See the above code, it will take you to a new route name AppIntroductionScreen. OffNamedUntil will remove…
Flutter Timer App With Getx
Learn how to build a timer app using Getx. Create a controller and declare variables like below In the Controller we declared Timer object _timer, and remainSeconds for checking on the remaining seconds and then a time variable. This time variable would be reactive. It means we Timer object’s return value would be saved time…
Flutter BLoc Http Get Example
Here you will learn how to use http bloc example The code for main.dart The code for data_screen.dart The code for repository.dart The code for app_events.dart The code for app_blocs.dart The code for user_model.dart
Flutter Go Router Go vs Push
Previously we have seen how to navigate to different screens using go router. In this section we will take a closer look how to use context.go() and context.push() GoRouter uses context.go() and context.push(). They all push new screens to the stack. context.go() removes all the previous stacks context.push() keeps the earlier stacks. If you learn…
Flutter BLoC Http Post Request
Previously we have covered BLoC http get request. Now we do post request here. Flutter BLoC http post request example. Using bloc post request could be scary for beginners. Here I have covered in detail about post request. First create a repository. This repository would connect to the server and post data. This is where…