5 Reasons why I use GetX for my application state management
Tags: flutter, dart
Published: 2021-02-11 18:28:29

As I wrote in my last [article](https://dev.to/mjablecnik/most-popular-flutter-libraries-for-state-management-l53)

GetX is one from 3 of the most popular and active maintained state managers and here are some reasons why I like it:
<br>
## 1) Increasing popularity:
Although is here only one year and is younger then Bloc or Provider, his popularity grow very rapidly.

Below in the graph you can see how the popularity is growing compared with other State managers in last 3 years:

![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v2lgvlm7p590g4efg1lr.png)
[Link to source](https://star-history.t9t.io/#jonataslaw/getx&rrousselGit/provider&felangel/bloc&fluttercommunity/get_it&rrousselGit/river_pod&mobxjs/mobx.dart&brianegan/flutter_redux)

You can see that GetX is growing up with the same speed as Bloc one year ago which is the most popular state management library in Flutter today.

So we can suppose that this grow will be continue also in the future.
<br>
## 2) Simplicity
For me as for beginner was very hard to work with Bloc, understand how streams works and create some useful app in short time. 
With Provider it was better but result code wasn't so pretty and readability was a little worse. 
But with GetX was development very pleasure. Firstly I understood a lot in very short time. I cannot write a lot of code and I can fully focus to my application development without finding why something doesn't work.
<br>
## 3) Very short code:
Here you can see a simple comparison how number lines of code take the one same list_detail_mvc application written in different state managers:
![alt text](https://dev-to-uploads.s3.amazonaws.com/i/ztnvoqrbtodmycjbnguy.png)
   
[Link to source](https://github.com/mjablecnik/new_flutter_template/blob/main/evaluations/line-count.md)

You can see that with GetX application take only 132 lines of code which is lower than same application written with any other popular State manager.

So it can be also reason why use GetX because with less code you can have also less bugs and better overview in the project.
<br>
## 4) You don't need a StatefulWidget:
With GetX you cannot use a StatefulWidget. 
Instead of it you use **GetxController** with Obx or GetBuilder for state updates and **GetView** which you can use instead of StatelessWidget.

All together give you a cleaner code without any useless boilerplate:

![alt text](https://dev-to-uploads.s3.amazonaws.com/i/y2hibtal0vg3d8x9ifsu.png)

![alt text](https://dev-to-uploads.s3.amazonaws.com/i/ryp67zxeie1lgs30u2at.png)

[Source code is here](https://github.com/mjablecnik/new_flutter_template/tree/main/evaluations/list_detail_mvc_getx)
<br>
## 5) Not only a state manager:
GetX contains all ecosystem useful packages where is: **State manager**, **Dependency manager**, **Navigation manager**, **Internationalization** and other very handy functions which make your development more simple and coding will be faster without any useless boilerplate code.
So you cannot use many different packages but you import only one and use everything what can gives you.
For more info look into:
[GetX Ecosystem - State Management](https://medium.com/flutter-community/the-flutter-getx-ecosystem-state-management-881c7235511d)
[GetX Ecosystem - Dependency injection](https://medium.com/flutter-community/the-flutter-getx-ecosystem-dependency-injection-8e763d0ec6b9)

Or official [GetX documentation](https://github.com/jonataslaw/getx/tree/master/documentation/en_US)

If you also want to see some code, you can look into my [Github repositories](https://github.com/mjablecnik?tab=repositories) where I have a lot of small projects written with GetX when I has been learning with Flutter.
<br>

I hope this article is useful for you and if yes, let me know it by give a like or some small comments below.. ;) 

<br>
Edit: After one year later I released my new article about GetX:
 {% link https://dev.to/mjablecnik/5-reasons-why-i-dont-use-getx-for-application-state-management-in-flutter-4d5m %}