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.
Month: October 2022
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…
How to Use Getx and BLoC Together
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…