Flutter BLoC state is an amazing object. It’s store all the data related to that BLoC class or Cubit class. If you use int, String, List or Map type object in your BLoC or Cubit class, You can find all of them from the state object. state is State object. State class extends Object class,…
Emit all the states in flutter bloc or cubit
It’s easy to emit() all the states in flutter bloc or cubit. Just do the below If you are using Cubit, then call the above code from inside a method() in your extended cubit class. If you are using BLoC, then call the above code from inside event() in your extended BLoC class. Inside the…
Dart lastWhere() function
Learn about dart lastWhere() function with example. You may use this to find the last smallest or last biggest element in List or Queue. It would be 2 as printed result. Because 2 is the smallest until the last element in the last query. here it will print 5 as the biggest one.
Flutter MultiBlocProvider With HydratedBLoC
Learn about flutter MultiBlocProvider with HydratedBLoC. To use them together, we need install them both Your bloc or cubit must extend HydratedBloc or HydratedCubit to do it. They both need to store data in the device in a directory. These directories could be created by the app. For this, we need to install another plugin….
Flutter BLoC update item in the list
We will learn how to update flutter bloc item in the list. First then you have to know that when you are creating a bloc or cubit using flutter_bloc, you have to create state classes and as you extend bloc or cubit, then you have mention the type of the state class in a List….
Flutter TextSelection.collapsed() for Cursor
If you want to set the cursor position at the end of the text value or text field, then TextSelection.collapsed() is useful. It works together with TextEditingController(). Here offset plays an important rule where the cursor is placed. With current offset, the cursor would be placed right after each letter as you type. You may…
Dart & Flutter fold() Example
You can do some interesting things using dart fold() function like sum of some values, the largest or smallest number from a list, In Flutter using dart fold() method solves a problem where you want to add or accumulate collective information. For if you have a list of integers and you wanna add all the…
How to create a list of widgets in flutter
Let’s learn how to generate a list of widgets in flutter. To create a list of widgets in Flutter we can use List.generate() function. It looks like below So you see that it takes length, it means number of objects you wanna create. Then it takes a function, that function should be responsible for generating…
Flutter ExpansionPanelList.radio and ExpansionPanelRadio()
Flutter ExpansionPanelList.radio widget is excellent for showing and hiding panel and it’s description. With ExpansionPanelList.radio, we can make sure if you tap on a new panel, the older one close automatically. ExpansionPanelList.radio internally could use ExpansionPanelRadio() widget to show more items. ExpansionPanelList.radio() could be suitable for complex JSON or Map data structure.
Flutter Custom Snackbar
Here, we will see how to create a custom snackbar using Getx. To achieve this result we will use Get.snackbar(). If you see If you see snackbar() function you will notice that you can do tons of things with it. So to create a custom snackbar we will customize it. First we will create a…