Flutter Getx

It's a time for knowing getx. Let's go. 

Getx


GetX is a fast, stable, and light state management library in flutter. There are so many State Management libraries in flutter like MobX, BLoC, Redux, Provider, etc. GetX is also a powerful micro framework and using this, we can manage states, make routing, and can perform dependency injection.


Three Principles of GetX:

  • Performance: GetX mainly focuses on better performance and minimum usage of resources, so in my humble opinion, it’s the best among other state management techniques.
  • Productivity: GetX has easy-to-remember syntax besides its top-notch performance. It saves a lot of time for the developers and increases the speed of the app by reducing the usage of resources.
  • Organization: GetX allows us to do away with business logic on views and separate dependency injection and navigation from the UI. You don’t require the context to navigate between screens. You don’t need to inject your controllers/models/blocs classes into the widget tree via multiproviders. For this GetX uses its own dependency injection feature.

Features of Getx:

* Managing State.
* Route management
* Theme management
* Localization

GetX Managements:

  • State Management: There are two types of state management:
    • Simple State Manager: It uses GetBuilder.
    • Reactive State Manager: It uses GetX and Obx.
  • Route Management: If we want to make Widgets like Snackbar, Bottomsheets, dialogs, etc. Then we can use GetX for it because GetX can build these widgets without using context.
  • Dependency Management: If we want to fetch data from other Class then with the help of GetX, we can do this in just a single line of code. Eg: Get.put()


Get CLI:
It's very easiest way to create views, controllers, modules in one single line using get_cli. 

For activate:
flutter pub global activate get_cli


Create project:
get create project: name_of_project


Create page:
get create page: name_of_page


Getx vs Bloc vs Riverpod


It's common confusion happens to all flutter developers. If you want to organize your state and business logic at high level, definitely you can go for Bloc. It's most suggest. But It's not an easiest to achieve it. Lots of boilerplate codes, lots of classes and methods of states, event and bloc. 

Riverpod is another fine state management library, It's extended version of provider, having a lots of features. 

But in meantime, when you want to keep your code simple and manage your states easier then go for Getx. Don't be doubt. Can be use in complexed project too. 

Comments

Popular posts from this blog

Flutter Bloc - Clean Architecture

What's new in android 14?

Dependencies vs Dev Dependencies in Flutter