Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.
preface
GetX is very popular on both Pub and Github, and as a feature-rich plugin it helps us do the following:
- Theme switch: for example, dark mode switch;
- Multi-language: This parameter can be configured
Map
Deal with multiple languages; - Popup alert: Yes
SnackBar
And dialog box; - Routing: no need
Context
Route jump; - Offline storage: Does not rely on native offline storage
GetStorage
; - State management: fast access responsive state management;
- Tools: for example, form validation tools, get system parameters (platform type, screen size, etc.);
- Dependency injection containers: Use simple
put
和find
Method to register and retrieve container objects; - Network request: Available
GetConnect
Complete the network request.
GetX is a plugin that gets most of the basics done.
Nothing is perfect, so what’s wrong with GetX? Let’s see what our foreign friends say.
GetX author background
I did some research on GetX’s founder, Jonny Borges, a brother of an Internet company (iris.Finance) that makes social apps for the stock market. GitHub is a small company with Jonny Borges as one of the founding team, so GitHub’s resume should be full stack. It is worth mentioning that there seem to be two Chinese (or Chinese) in the company.
Their App promotional picture is as follows, look at the interface is very good. I also downloaded their application, although it supports mobile phone registration in mainland China, but failed to receive the verification code, so I had to give up.
Of course, GetX has over 130 participants so far, and the future should be even better.
Objective evaluation of GetX
The reason I put objective in quotes is because I found out that the author of this article created a state management plugin called Flutter_meedu, which is benchmarked to GetX, so you can feel for yourself as to whether it’s objective or not. Flutter – Should I use GetX?
- Navigation using GetX requires custom navigation
MaterialApp
或CupertinoApp
That is we need to useGetMeterialApp
或GetCupertinoApp
Wrap the application so it doesn’t need to be used when the page jumpsBuildContext
. It is highly invasive to application. - Snackbars, dialogs, and navigation are not used properly. Static is used internally within these implementations
context
This prevents unit testing from being done directly and requires widget Testing. get_connect
The plug-in integrates REST API requests with the GraphQL client. This is a bit redundant, and most applications don’t use both, which makes the plugin redundant (Dio is still recommended for web requests).- Dependency injection and hot reload issues: GetX’s dependency injection is not yet mature. If the dependency object is changed (for example, changing the dependency object type, adding a dependency object), hot reload will cause an error.
- Comments and documentation are poor (I agree) : many parts of the source code are missing comments, which can make future maintenance more difficult. The official documentation is also less than perfect, leaving users to find out for themselves (indeed, a lot of this was done while writing the series).
- The code is poorly organized: if you read the source code, you’ll find hundreds of lines in a file, with multiple classes, functions, and variables all mixed up in a single file. At the same time, the naming of some methods also needs to be improved, such as routing
Get.to
.Get.toNamed
.Get.offNamed
Dependency injectionGet.put
.Get.lazyPut
These method names are hard to infer without reading the documentation. It makes more sense to add a module name between the method and Get, for exampleGet.router.to
.Get.dependencies.put
. - A lot of code is untested: Because GetX covers so much functionality, it’s hard to fully test every feature, which can lead to hidden bugs.
- Tips for using GetX: It is recommended to use only the necessary modules, such as GetX’s state management, reactive programming, and dependency injection, and to use functions like navigation and binding sparingly.
Despite these issues, GetX is a powerful plug-in, but in practice you need to be careful about the risks of adopting GetX entirely.
conclusion
From abroad the author’s evaluation and my actual experience, the author said relatively objective. With the improvement of the Flutter ecosystem, there are many alternatives to GetX’s features in Flutter development. Therefore, it is recommended not to use all of them in order to simplify Flutter development. As a result, if GetX has problems or fails to upgrade properly, the maintenance and upgrade of the whole application may be a huge workload.
I am dao Code Farmer with the same name as my wechat official account. This is a column about the introduction and practice of Flutter, providing systematic learning articles about Flutter. See the corresponding source code here: The source code of Flutter Introduction and Practical column. If you have any questions, please add me to the wechat account: island-coder.
👍🏻 : feel the harvest please point a praise to encourage!
🌟 : Collect articles, easy to look back!
💬 : Comment exchange, mutual progress!