Ashiqur Rahman Alif
Committed by GitHub

Updated Table of Contents in Bengali

Showing 1 changed file with 1207 additions and 0 deletions
  1 +![](https://raw.githubusercontent.com/jonataslaw/getx-community/master/get.png)
1 2
  3 +[![pub package](https://img.shields.io/pub/v/get.svg?label=get&color=blue)](https://pub.dev/packages/get)
  4 +[![popularity](https://img.shields.io/pub/popularity/get?logo=dart)](https://pub.dev/packages/get/score)
  5 +[![likes](https://img.shields.io/pub/likes/get?logo=dart)](https://pub.dev/packages/get/score)
  6 +[![pub points](https://img.shields.io/pub/points/sentry?logo=dart)](https://pub.dev/packages/get/score)
  7 +![building](https://github.com/jonataslaw/get/workflows/build/badge.svg)
  8 +[![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://pub.dev/packages/effective_dart)
  9 +[![Discord Shield](https://img.shields.io/discord/722900883784073290.svg?logo=discord)](https://discord.com/invite/9Hpt99N)
  10 +[![Get on Slack](https://img.shields.io/badge/slack-join-orange.svg)](https://communityinviter.com/apps/getxworkspace/getx)
  11 +[![Telegram](https://img.shields.io/badge/chat-on%20Telegram-blue.svg)](https://t.me/joinchat/PhdbJRmsZNpAqSLJL6bH7g)
  12 +<a href="https://github.com/Solido/awesome-flutter">
  13 +<img alt="Awesome Flutter" src="https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square" />
  14 +</a>
  15 +<a href="https://www.buymeacoffee.com/jonataslaw" target="_blank"><img src="https://i.imgur.com/aV6DDA7.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important; box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" > </a>
  16 +
  17 +![](https://raw.githubusercontent.com/jonataslaw/getx-community/master/getx.png)
  18 +
  19 +
  20 +- [Get সম্পর্কে](#about-get)
  21 +- [কিভাবে ইনস্টল করতে হবে](#installing)
  22 +- [GetX দিয়ে কাউন্টার অ্যাপ তৈরি করুন](#counter-app-with-getx)
  23 +- [GetX এর তিনটি স্তম্ভ](#the-three-pillars)
  24 + - [স্টেট ব্যবস্থাপনা](#state-management)
  25 + - [Reactive স্টেট ম্যানেজার](#reactive-state-manager)
  26 + - [স্টেট ব্যবস্থাপনা সম্পর্কে আরো বিস্তারিত](#more-details-about-state-management)
  27 + - [রুট ব্যবস্থাপনা](#route-management)
  28 + - [রুট ব্যবস্থাপনা সম্পর্কে আরো বিস্তারিত](#more-details-about-route-management)
  29 + - [ডিপেনডেন্সি ব্যবস্থাপনা](#dependency-management)
  30 + - [ডিপেনডেন্সি ব্যবস্থাপনা সম্পর্কে আরো বিস্তারিত](#more-details-about-dependency-management)
  31 +- [ইউটিলিটি](#utils)
  32 + - [আন্তর্জাতিকীকরণ](#internationalization)
  33 + - [অনুবাদ](#translations)
  34 + - [অনুবাদের ব্যবহার](#using-translations)
  35 + - [লোকেল](#locales)
  36 + - [লোকেল পরিবর্তন করুন](#change-locale)
  37 + - [লোকেল পদ্ধতি](#system-locale)
  38 + - [থিম পরিবর্তন করুন](#change-theme)
  39 + - [GetConnect](#getconnect)
  40 + - [ডিফল্ট কনফিগারেশন](#default-configuration)
  41 + - [কাস্টম কনফিগারেশন](#custom-configuration)
  42 + - [GetPage মিডিলওয়্যার](#getpage-middleware)
  43 + - [Priority](#priority)
  44 + - [Redirect](#redirect)
  45 + - [onPageCalled](#onpagecalled)
  46 + - [OnBindingsStart](#onbindingsstart)
  47 + - [OnPageBuildStart](#onpagebuildstart)
  48 + - [OnPageBuilt](#onpagebuilt)
  49 + - [OnPageDispose](#onpagedispose)
  50 + - [অন্যান্য APIs](#other-advanced-apis)
  51 + - [ঐচ্ছিক গ্লোবাল সেটিংস এবং ম্যানুয়াল কনফিগারেশন](#optional-global-settings-and-manual-configurations)
  52 + - [লোকাল স্টেট উইজেট](#local-state-widgets)
  53 + - [ValueBuilder](#valuebuilder)
  54 + - [ObxValue](#obxvalue)
  55 + - [প্রয়োজনীয় পরামর্শ](#useful-tips)
  56 + - [GetView](#getview)
  57 + - [GetResponsiveView](#getresponsiveview)
  58 + - [কিভাবে এটি ব্যবহার করতে হয়](#how-to-use-it)
  59 + - [GetWidget](#getwidget)
  60 + - [GetxService](#getxservice)
  61 +- [2.0 থেকে পরিবর্তন](#breaking-changes-from-20)
  62 +- [কেন Getx ব্যবহার করবেন?](#why-getx)
  63 +
  64 +# About Get
  65 +
  66 +- GetX is an extra-light and powerful solution for Flutter. It combines high-performance state management, intelligent dependency injection, and route management quickly and practically.
  67 +
  68 +- GetX has 3 basic principles. This means that these are the priority for all resources in the library: **PRODUCTIVITY, PERFORMANCE AND ORGANIZATION.**
  69 +
  70 + - **PERFORMANCE:** GetX is focused on performance and minimum consumption of resources. GetX does not use Streams or ChangeNotifier.
  71 +
  72 + - **PRODUCTIVITY:** GetX uses an easy and pleasant syntax. No matter what you want to do, there is always an easier way with GetX. It will save hours of development and will provide the maximum performance your application can deliver.
  73 +
  74 + Generally, the developer should be concerned with removing controllers from memory. With GetX this is not necessary because resources are removed from memory when they are not used by default. If you want to keep it in memory, you must explicitly declare "permanent: true" in your dependency. That way, in addition to saving time, you are less at risk of having unnecessary dependencies on memory. Dependency loading is also lazy by default.
  75 +
  76 + - **ORGANIZATION:** GetX allows the total decoupling of the View, presentation logic, business logic, dependency injection, and navigation. You do not need context to navigate between routes, so you are not dependent on the widget tree (visualization) for this. You don't need context to access your controllers/blocs through an inheritedWidget, so you completely decouple your presentation logic and business logic from your visualization layer. You do not need to inject your Controllers/Models/Blocs classes into your widget tree through `MultiProvider`s. For this, GetX uses its own dependency injection feature, decoupling the DI from its view completely.
  77 +
  78 + With GetX you know where to find each feature of your application, having clean code by default. In addition to making maintenance easy, this makes the sharing of modules something that until then in Flutter was unthinkable, something totally possible.
  79 + BLoC was a starting point for organizing code in Flutter, it separates business logic from visualization. GetX is a natural evolution of this, not only separating the business logic but the presentation logic. Bonus injection of dependencies and routes are also decoupled, and the data layer is out of it all. You know where everything is, and all of this in an easier way than building a hello world.
  80 + GetX is the easiest, practical, and scalable way to build high-performance applications with the Flutter SDK. It has a large ecosystem around it that works perfectly together, it's easy for beginners, and it's accurate for experts. It is secure, stable, up-to-date, and offers a huge range of APIs built-in that are not present in the default Flutter SDK.
  81 +
  82 +- GetX is not bloated. It has a multitude of features that allow you to start programming without worrying about anything, but each of these features are in separate containers and are only started after use. If you only use State Management, only State Management will be compiled. If you only use routes, nothing from the state management will be compiled.
  83 +
  84 +- GetX has a huge ecosystem, a large community, a large number of collaborators, and will be maintained as long as the Flutter exists. GetX too is capable of running with the same code on Android, iOS, Web, Mac, Linux, Windows, and on your server.
  85 + **It is possible to fully reuse your code made on the frontend on your backend with [Get Server](https://github.com/jonataslaw/get_server)**.
  86 +
  87 +**In addition, the entire development process can be completely automated, both on the server and on the front end with [Get CLI](https://github.com/jonataslaw/get_cli)**.
  88 +
  89 +**In addition, to further increase your productivity, we have the
  90 +[extension to VSCode](https://marketplace.visualstudio.com/items?itemName=get-snippets.get-snippets) and the [extension to Android Studio/Intellij](https://plugins.jetbrains.com/plugin/14975-getx-snippets)**
  91 +
  92 +# Installing
  93 +
  94 +Add Get to your pubspec.yaml file:
  95 +
  96 +```yaml
  97 +dependencies:
  98 + get:
  99 +```
  100 +
  101 +Import get in files that it will be used:
  102 +
  103 +```dart
  104 +import 'package:get/get.dart';
  105 +```
  106 +
  107 +# Counter App with GetX
  108 +
  109 +The "counter" project created by default on new project on Flutter has over 100 lines (with comments). To show the power of Get, I will demonstrate how to make a "counter" changing the state with each click, switching between pages and sharing the state between screens, all in an organized way, separating the business logic from the view, in ONLY 26 LINES CODE INCLUDING COMMENTS.
  110 +
  111 +- Step 1:
  112 + Add "Get" before your MaterialApp, turning it into GetMaterialApp
  113 +
  114 +```dart
  115 +void main() => runApp(GetMaterialApp(home: Home()));
  116 +```
  117 +
  118 +- Note: this does not modify the MaterialApp of the Flutter, GetMaterialApp is not a modified MaterialApp, it is just a pre-configured Widget, which has the default MaterialApp as a child. You can configure this manually, but it is definitely not necessary. GetMaterialApp will create routes, inject them, inject translations, inject everything you need for route navigation. If you use Get only for state management or dependency management, it is not necessary to use GetMaterialApp. GetMaterialApp is necessary for routes, snackbars, internationalization, bottomSheets, dialogs, and high-level apis related to routes and absence of context.
  119 +- Note²: This step is only necessary if you gonna use route management (`Get.to()`, `Get.back()` and so on). If you not gonna use it then it is not necessary to do step 1
  120 +
  121 +- Step 2:
  122 + Create your business logic class and place all variables, methods and controllers inside it.
  123 + You can make any variable observable using a simple ".obs".
  124 +
  125 +```dart
  126 +class Controller extends GetxController{
  127 + var count = 0.obs;
  128 + increment() => count++;
  129 +}
  130 +```
  131 +
  132 +- Step 3:
  133 + Create your View, use StatelessWidget and save some RAM, with Get you may no longer need to use StatefulWidget.
  134 +
  135 +```dart
  136 +class Home extends StatelessWidget {
  137 +
  138 + @override
  139 + Widget build(context) {
  140 +
  141 + // Instantiate your class using Get.put() to make it available for all "child" routes there.
  142 + final Controller c = Get.put(Controller());
  143 +
  144 + return Scaffold(
  145 + // Use Obx(()=> to update Text() whenever count is changed.
  146 + appBar: AppBar(title: Obx(() => Text("Clicks: ${c.count}"))),
  147 +
  148 + // Replace the 8 lines Navigator.push by a simple Get.to(). You don't need context
  149 + body: Center(child: ElevatedButton(
  150 + child: Text("Go to Other"), onPressed: () => Get.to(Other()))),
  151 + floatingActionButton:
  152 + FloatingActionButton(child: Icon(Icons.add), onPressed: c.increment));
  153 + }
  154 +}
  155 +
  156 +class Other extends StatelessWidget {
  157 + // You can ask Get to find a Controller that is being used by another page and redirect you to it.
  158 + final Controller c = Get.find();
  159 +
  160 + @override
  161 + Widget build(context){
  162 + // Access the updated count variable
  163 + return Scaffold(body: Center(child: Text("${c.count}")));
  164 + }
  165 +}
  166 +```
  167 +
  168 +Result:
  169 +
  170 +![](https://raw.githubusercontent.com/jonataslaw/getx-community/master/counter-app-gif.gif)
  171 +
  172 +This is a simple project but it already makes clear how powerful Get is. As your project grows, this difference will become more significant.
  173 +
  174 +Get was designed to work with teams, but it makes the job of an individual developer simple.
  175 +
  176 +Improve your deadlines, deliver everything on time without losing performance. Get is not for everyone, but if you identified with that phrase, Get is for you!
  177 +
  178 +# The Three pillars
  179 +
  180 +## State management
  181 +
  182 +Get has two different state managers: the simple state manager (we'll call it GetBuilder) and the reactive state manager (GetX/Obx)
  183 +
  184 +### Reactive State Manager
  185 +
  186 +Reactive programming can alienate many people because it is said to be complicated. GetX turns reactive programming into something quite simple:
  187 +
  188 +- You won't need to create StreamControllers.
  189 +- You won't need to create a StreamBuilder for each variable
  190 +- You will not need to create a class for each state.
  191 +- You will not need to create a get for an initial value.
  192 +- You will not need to use code generators
  193 +
  194 +Reactive programming with Get is as easy as using setState.
  195 +
  196 +Let's imagine that you have a name variable and want that every time you change it, all widgets that use it are automatically changed.
  197 +
  198 +This is your count variable:
  199 +
  200 +```dart
  201 +var name = 'Ashiqur Rahman Alif';
  202 +```
  203 +
  204 +To make it observable, you just need to add ".obs" to the end of it:
  205 +
  206 +```dart
  207 +var name = 'Ashiqur Rahman Alif'.obs;
  208 +```
  209 +
  210 +And in the UI, when you want to show that value and update the screen whenever the values changes, simply do this:
  211 +
  212 +```dart
  213 +Obx(() => Text("${controller.name}"));
  214 +```
  215 +
  216 +That's all. It's _that_ simple.
  217 +
  218 +### More details about state management
  219 +
  220 +**See an more in-depth explanation of state management [here](./documentation/en_US/state_management.md). There you will see more examples and also the difference between the simple state manager and the reactive state manager**
  221 +
  222 +You will get a good idea of GetX power.
  223 +
  224 +## Route management
  225 +
  226 +If you are going to use routes/snackbars/dialogs/bottomsheets without context, GetX is excellent for you too, just see it:
  227 +
  228 +Add "Get" before your MaterialApp, turning it into GetMaterialApp
  229 +
  230 +```dart
  231 +GetMaterialApp( // Before: MaterialApp(
  232 + home: MyHome(),
  233 +)
  234 +```
  235 +
  236 +Navigate to a new screen:
  237 +
  238 +```dart
  239 +
  240 +Get.to(NextScreen());
  241 +```
  242 +
  243 +Navigate to new screen with name. See more details on named routes [here](./documentation/en_US/route_management.md#navigation-with-named-routes)
  244 +
  245 +```dart
  246 +
  247 +Get.toNamed('/details');
  248 +```
  249 +
  250 +To close snackbars, dialogs, bottomsheets, or anything you would normally close with Navigator.pop(context);
  251 +
  252 +```dart
  253 +Get.back();
  254 +```
  255 +
  256 +To go to the next screen and no option to go back to the previous screen (for use in SplashScreens, login screens, etc.)
  257 +
  258 +```dart
  259 +Get.off(NextScreen());
  260 +```
  261 +
  262 +To go to the next screen and cancel all previous routes (useful in shopping carts, polls, and tests)
  263 +
  264 +```dart
  265 +Get.offAll(NextScreen());
  266 +```
  267 +
  268 +Noticed that you didn't have to use context to do any of these things? That's one of the biggest advantages of using Get route management. With this, you can execute all these methods from within your controller class, without worries.
  269 +
  270 +### More details about route management
  271 +
  272 +**Get works with named routes and also offers lower-level control over your routes! There is in-depth documentation [here](./documentation/en_US/route_management.md)**
  273 +
  274 +## Dependency management
  275 +
  276 +Get has a simple and powerful dependency manager that allows you to retrieve the same class as your Bloc or Controller with just 1 lines of code, no Provider context, no inheritedWidget:
  277 +
  278 +```dart
  279 +Controller controller = Get.put(Controller()); // Rather Controller controller = Controller();
  280 +```
  281 +
  282 +- Note: If you are using Get's State Manager, pay more attention to the bindings API, which will make it easier to connect your view to your controller.
  283 +
  284 +Instead of instantiating your class within the class you are using, you are instantiating it within the Get instance, which will make it available throughout your App.
  285 +So you can use your controller (or class Bloc) normally
  286 +
  287 +**Tip:** Get dependency management is decoupled from other parts of the package, so if for example, your app is already using a state manager (any one, it doesn't matter), you don't need to rewrite it all, you can use this dependency injection with no problems at all
  288 +
  289 +```dart
  290 +controller.fetchApi();
  291 +```
  292 +
  293 +Imagine that you have navigated through numerous routes, and you need data that was left behind in your controller, you would need a state manager combined with the Provider or Get_it, correct? Not with Get. You just need to ask Get to "find" for your controller, you don't need any additional dependencies:
  294 +
  295 +```dart
  296 +Controller controller = Get.find();
  297 +//Yes, it looks like Magic, Get will find your controller, and will deliver it to you. You can have 1 million controllers instantiated, Get will always give you the right controller.
  298 +```
  299 +
  300 +And then you will be able to recover your controller data that was obtained back there:
  301 +
  302 +```dart
  303 +Text(controller.textFromApi);
  304 +```
  305 +
  306 +### More details about dependency management
  307 +
  308 +**See a more in-depth explanation of dependency management [here](./documentation/en_US/dependency_management.md)**
  309 +
  310 +# Utils
  311 +
  312 +## Internationalization
  313 +
  314 +### Translations
  315 +
  316 +Translations are kept as a simple key-value dictionary map.
  317 +To add custom translations, create a class and extend `Translations`.
  318 +
  319 +```dart
  320 +import 'package:get/get.dart';
  321 +
  322 +class Messages extends Translations {
  323 + @override
  324 + Map<String, Map<String, String>> get keys => {
  325 + 'en_US': {
  326 + 'hello': 'Hello World',
  327 + },
  328 + 'de_DE': {
  329 + 'hello': 'Hallo Welt',
  330 + }
  331 + };
  332 +}
  333 +```
  334 +
  335 +#### Using translations
  336 +
  337 +Just append `.tr` to the specified key and it will be translated, using the current value of `Get.locale` and `Get.fallbackLocale`.
  338 +
  339 +```dart
  340 +Text('title'.tr);
  341 +```
  342 +
  343 +#### Using translation with singular and plural
  344 +
  345 +```dart
  346 +var products = [];
  347 +Text('singularKey'.trPlural('pluralKey', products.length, Args));
  348 +```
  349 +
  350 +#### Using translation with parameters
  351 +
  352 +```dart
  353 +import 'package:get/get.dart';
  354 +
  355 +
  356 +Map<String, Map<String, String>> get keys => {
  357 + 'en_US': {
  358 + 'logged_in': 'logged in as @name with email @email',
  359 + },
  360 + 'es_ES': {
  361 + 'logged_in': 'iniciado sesión como @name con e-mail @email',
  362 + }
  363 +};
  364 +
  365 +Text('logged_in'.trParams({
  366 + 'name': 'Jhon',
  367 + 'email': 'jhon@example.com'
  368 + }));
  369 +```
  370 +
  371 +### Locales
  372 +
  373 +Pass parameters to `GetMaterialApp` to define the locale and translations.
  374 +
  375 +```dart
  376 +return GetMaterialApp(
  377 + translations: Messages(), // your translations
  378 + locale: Locale('en', 'US'), // translations will be displayed in that locale
  379 + fallbackLocale: Locale('en', 'UK'), // specify the fallback locale in case an invalid locale is selected.
  380 +);
  381 +```
  382 +
  383 +#### Change locale
  384 +
  385 +Call `Get.updateLocale(locale)` to update the locale. Translations then automatically use the new locale.
  386 +
  387 +```dart
  388 +var locale = Locale('en', 'US');
  389 +Get.updateLocale(locale);
  390 +```
  391 +
  392 +#### System locale
  393 +
  394 +To read the system locale, you could use `Get.deviceLocale`.
  395 +
  396 +```dart
  397 +return GetMaterialApp(
  398 + locale: Get.deviceLocale,
  399 +);
  400 +```
  401 +
  402 +## Change Theme
  403 +
  404 +Please do not use any higher level widget than `GetMaterialApp` in order to update it. This can trigger duplicate keys. A lot of people are used to the prehistoric approach of creating a "ThemeProvider" widget just to change the theme of your app, and this is definitely NOT necessary with **GetX™**.
  405 +
  406 +You can create your custom theme and simply add it within `Get.changeTheme` without any boilerplate for that:
  407 +
  408 +```dart
  409 +Get.changeTheme(ThemeData.light());
  410 +```
  411 +
  412 +If you want to create something like a button that changes the Theme in `onTap`, you can combine two **GetX™** APIs for that:
  413 +
  414 +- The api that checks if the dark `Theme` is being used.
  415 +- And the `Theme` Change API, you can just put this within an `onPressed`:
  416 +
  417 +```dart
  418 +Get.changeTheme(Get.isDarkMode? ThemeData.light(): ThemeData.dark());
  419 +```
  420 +
  421 +When `.darkmode` is activated, it will switch to the _light theme_, and when the _light theme_ becomes active, it will change to _dark theme_.
  422 +
  423 +## GetConnect
  424 +
  425 +GetConnect is an easy way to communicate from your back to your front with http or websockets
  426 +
  427 +### Default configuration
  428 +
  429 +You can simply extend GetConnect and use the GET/POST/PUT/DELETE/SOCKET methods to communicate with your Rest API or websockets.
  430 +
  431 +```dart
  432 +class UserProvider extends GetConnect {
  433 + // Get request
  434 + Future<Response> getUser(int id) => get('http://youapi/users/$id');
  435 + // Post request
  436 + Future<Response> postUser(Map data) => post('http://youapi/users', body: data);
  437 + // Post request with File
  438 + Future<Response<CasesModel>> postCases(List<int> image) {
  439 + final form = FormData({
  440 + 'file': MultipartFile(image, filename: 'avatar.png'),
  441 + 'otherFile': MultipartFile(image, filename: 'cover.png'),
  442 + });
  443 + return post('http://youapi/users/upload', form);
  444 + }
  445 +
  446 + GetSocket userMessages() {
  447 + return socket('https://yourapi/users/socket');
  448 + }
  449 +}
  450 +```
  451 +
  452 +### Custom configuration
  453 +
  454 +GetConnect is highly customizable You can define base Url, as answer modifiers, as Requests modifiers, define an authenticator, and even the number of attempts in which it will try to authenticate itself, in addition to giving the possibility to define a standard decoder that will transform all your requests into your Models without any additional configuration.
  455 +
  456 +```dart
  457 +class HomeProvider extends GetConnect {
  458 + @override
  459 + void onInit() {
  460 + // All request will pass to jsonEncode so CasesModel.fromJson()
  461 + httpClient.defaultDecoder = CasesModel.fromJson;
  462 + httpClient.baseUrl = 'https://api.covid19api.com';
  463 + // baseUrl = 'https://api.covid19api.com'; // It define baseUrl to
  464 + // Http and websockets if used with no [httpClient] instance
  465 +
  466 + // It's will attach 'apikey' property on header from all requests
  467 + httpClient.addRequestModifier((request) {
  468 + request.headers['apikey'] = '12345678';
  469 + return request;
  470 + });
  471 +
  472 + // Even if the server sends data from the country "Brazil",
  473 + // it will never be displayed to users, because you remove
  474 + // that data from the response, even before the response is delivered
  475 + httpClient.addResponseModifier<CasesModel>((request, response) {
  476 + CasesModel model = response.body;
  477 + if (model.countries.contains('Brazil')) {
  478 + model.countries.remove('Brazilll');
  479 + }
  480 + });
  481 +
  482 + httpClient.addAuthenticator((request) async {
  483 + final response = await get("http://yourapi/token");
  484 + final token = response.body['token'];
  485 + // Set the header
  486 + request.headers['Authorization'] = "$token";
  487 + return request;
  488 + });
  489 +
  490 + //Autenticator will be called 3 times if HttpStatus is
  491 + //HttpStatus.unauthorized
  492 + httpClient.maxAuthRetries = 3;
  493 + }
  494 +
  495 + @override
  496 + Future<Response<CasesModel>> getCases(String path) => get(path);
  497 +}
  498 +```
  499 +
  500 +## GetPage Middleware
  501 +
  502 +The GetPage has now new property that takes a list of GetMiddleWare and run them in the specific order.
  503 +
  504 +**Note**: When GetPage has a Middlewares, all the children of this page will have the same middlewares automatically.
  505 +
  506 +### Priority
  507 +
  508 +The Order of the Middlewares to run can be set by the priority in the GetMiddleware.
  509 +
  510 +```dart
  511 +final middlewares = [
  512 + GetMiddleware(priority: 2),
  513 + GetMiddleware(priority: 5),
  514 + GetMiddleware(priority: 4),
  515 + GetMiddleware(priority: -8),
  516 +];
  517 +```
  518 +
  519 +those middlewares will be run in this order **-8 => 2 => 4 => 5**
  520 +
  521 +### Redirect
  522 +
  523 +This function will be called when the page of the called route is being searched for. It takes RouteSettings as a result to redirect to. Or give it null and there will be no redirecting.
  524 +
  525 +```dart
  526 +RouteSettings redirect(String route) {
  527 + final authService = Get.find<AuthService>();
  528 + return authService.authed.value ? null : RouteSettings(name: '/login')
  529 +}
  530 +```
  531 +
  532 +### onPageCalled
  533 +
  534 +This function will be called when this Page is called before anything created
  535 +you can use it to change something about the page or give it new page
  536 +
  537 +```dart
  538 +GetPage onPageCalled(GetPage page) {
  539 + final authService = Get.find<AuthService>();
  540 + return page.copyWith(title: 'Welcome ${authService.UserName}');
  541 +}
  542 +```
  543 +
  544 +### OnBindingsStart
  545 +
  546 +This function will be called right before the Bindings are initialize.
  547 +Here you can change Bindings for this page.
  548 +
  549 +```dart
  550 +List<Bindings> onBindingsStart(List<Bindings> bindings) {
  551 + final authService = Get.find<AuthService>();
  552 + if (authService.isAdmin) {
  553 + bindings.add(AdminBinding());
  554 + }
  555 + return bindings;
  556 +}
  557 +```
  558 +
  559 +### OnPageBuildStart
  560 +
  561 +This function will be called right after the Bindings are initialize.
  562 +Here you can do something after that you created the bindings and before creating the page widget.
  563 +
  564 +```dart
  565 +GetPageBuilder onPageBuildStart(GetPageBuilder page) {
  566 + print('bindings are ready');
  567 + return page;
  568 +}
  569 +```
  570 +
  571 +### OnPageBuilt
  572 +
  573 +This function will be called right after the GetPage.page function is called and will give you the result of the function. and take the widget that will be showed.
  574 +
  575 +### OnPageDispose
  576 +
  577 +This function will be called right after disposing all the related objects (Controllers, views, ...) of the page.
  578 +
  579 +## Other Advanced APIs
  580 +
  581 +```dart
  582 +// give the current args from currentScreen
  583 +Get.arguments
  584 +
  585 +// give name of previous route
  586 +Get.previousRoute
  587 +
  588 +// give the raw route to access for example, rawRoute.isFirst()
  589 +Get.rawRoute
  590 +
  591 +// give access to Routing API from GetObserver
  592 +Get.routing
  593 +
  594 +// check if snackbar is open
  595 +Get.isSnackbarOpen
  596 +
  597 +// check if dialog is open
  598 +Get.isDialogOpen
  599 +
  600 +// check if bottomsheet is open
  601 +Get.isBottomSheetOpen
  602 +
  603 +// remove one route.
  604 +Get.removeRoute()
  605 +
  606 +// back repeatedly until the predicate returns true.
  607 +Get.until()
  608 +
  609 +// go to next route and remove all the previous routes until the predicate returns true.
  610 +Get.offUntil()
  611 +
  612 +// go to next named route and remove all the previous routes until the predicate returns true.
  613 +Get.offNamedUntil()
  614 +
  615 +//Check in what platform the app is running
  616 +GetPlatform.isAndroid
  617 +GetPlatform.isIOS
  618 +GetPlatform.isMacOS
  619 +GetPlatform.isWindows
  620 +GetPlatform.isLinux
  621 +GetPlatform.isFuchsia
  622 +
  623 +//Check the device type
  624 +GetPlatform.isMobile
  625 +GetPlatform.isDesktop
  626 +//All platforms are supported independently in web!
  627 +//You can tell if you are running inside a browser
  628 +//on Windows, iOS, OSX, Android, etc.
  629 +GetPlatform.isWeb
  630 +
  631 +
  632 +// Equivalent to : MediaQuery.of(context).size.height,
  633 +// but immutable.
  634 +Get.height
  635 +Get.width
  636 +
  637 +// Gives the current context of the Navigator.
  638 +Get.context
  639 +
  640 +// Gives the context of the snackbar/dialog/bottomsheet in the foreground, anywhere in your code.
  641 +Get.contextOverlay
  642 +
  643 +// Note: the following methods are extensions on context. Since you
  644 +// have access to context in any place of your UI, you can use it anywhere in the UI code
  645 +
  646 +// If you need a changeable height/width (like Desktop or browser windows that can be scaled) you will need to use context.
  647 +context.width
  648 +context.height
  649 +
  650 +// Gives you the power to define half the screen, a third of it and so on.
  651 +// Useful for responsive applications.
  652 +// param dividedBy (double) optional - default: 1
  653 +// param reducedBy (double) optional - default: 0
  654 +context.heightTransformer()
  655 +context.widthTransformer()
  656 +
  657 +/// Similar to MediaQuery.of(context).size
  658 +context.mediaQuerySize()
  659 +
  660 +/// Similar to MediaQuery.of(context).padding
  661 +context.mediaQueryPadding()
  662 +
  663 +/// Similar to MediaQuery.of(context).viewPadding
  664 +context.mediaQueryViewPadding()
  665 +
  666 +/// Similar to MediaQuery.of(context).viewInsets;
  667 +context.mediaQueryViewInsets()
  668 +
  669 +/// Similar to MediaQuery.of(context).orientation;
  670 +context.orientation()
  671 +
  672 +/// Check if device is on landscape mode
  673 +context.isLandscape()
  674 +
  675 +/// Check if device is on portrait mode
  676 +context.isPortrait()
  677 +
  678 +/// Similar to MediaQuery.of(context).devicePixelRatio;
  679 +context.devicePixelRatio()
  680 +
  681 +/// Similar to MediaQuery.of(context).textScaleFactor;
  682 +context.textScaleFactor()
  683 +
  684 +/// Get the shortestSide from screen
  685 +context.mediaQueryShortestSide()
  686 +
  687 +/// True if width be larger than 800
  688 +context.showNavbar()
  689 +
  690 +/// True if the shortestSide is smaller than 600p
  691 +context.isPhone()
  692 +
  693 +/// True if the shortestSide is largest than 600p
  694 +context.isSmallTablet()
  695 +
  696 +/// True if the shortestSide is largest than 720p
  697 +context.isLargeTablet()
  698 +
  699 +/// True if the current device is Tablet
  700 +context.isTablet()
  701 +
  702 +/// Returns a value<T> according to the screen size
  703 +/// can give value for:
  704 +/// watch: if the shortestSide is smaller than 300
  705 +/// mobile: if the shortestSide is smaller than 600
  706 +/// tablet: if the shortestSide is smaller than 1200
  707 +/// desktop: if width is largest than 1200
  708 +context.responsiveValue<T>()
  709 +```
  710 +
  711 +### Optional Global Settings and Manual configurations
  712 +
  713 +GetMaterialApp configures everything for you, but if you want to configure Get manually.
  714 +
  715 +```dart
  716 +MaterialApp(
  717 + navigatorKey: Get.key,
  718 + navigatorObservers: [GetObserver()],
  719 +);
  720 +```
  721 +
  722 +You will also be able to use your own Middleware within `GetObserver`, this will not influence anything.
  723 +
  724 +```dart
  725 +MaterialApp(
  726 + navigatorKey: Get.key,
  727 + navigatorObservers: [
  728 + GetObserver(MiddleWare.observer) // Here
  729 + ],
  730 +);
  731 +```
  732 +
  733 +You can create _Global Settings_ for `Get`. Just add `Get.config` to your code before pushing any route.
  734 +Or do it directly in your `GetMaterialApp`
  735 +
  736 +```dart
  737 +GetMaterialApp(
  738 + enableLog: true,
  739 + defaultTransition: Transition.fade,
  740 + opaqueRoute: Get.isOpaqueRouteDefault,
  741 + popGesture: Get.isPopGestureEnable,
  742 + transitionDuration: Get.defaultDurationTransition,
  743 + defaultGlobalState: Get.defaultGlobalState,
  744 +);
  745 +
  746 +Get.config(
  747 + enableLog = true,
  748 + defaultPopGesture = true,
  749 + defaultTransition = Transitions.cupertino
  750 +)
  751 +```
  752 +
  753 +You can optionally redirect all the logging messages from `Get`.
  754 +If you want to use your own, favourite logging package,
  755 +and want to capture the logs there:
  756 +
  757 +```dart
  758 +GetMaterialApp(
  759 + enableLog: true,
  760 + logWriterCallback: localLogWriter,
  761 +);
  762 +
  763 +void localLogWriter(String text, {bool isError = false}) {
  764 + // pass the message to your favourite logging package here
  765 + // please note that even if enableLog: false log messages will be pushed in this callback
  766 + // you get check the flag if you want through GetConfig.isLogEnable
  767 +}
  768 +
  769 +```
  770 +
  771 +### Local State Widgets
  772 +
  773 +These Widgets allows you to manage a single value, and keep the state ephemeral and locally.
  774 +We have flavours for Reactive and Simple.
  775 +For instance, you might use them to toggle obscureText in a `TextField`, maybe create a custom
  776 +Expandable Panel, or maybe modify the current index in `BottomNavigationBar` while changing the content
  777 +of the body in a `Scaffold`.
  778 +
  779 +#### ValueBuilder
  780 +
  781 +A simplification of `StatefulWidget` that works with a `.setState` callback that takes the updated value.
  782 +
  783 +```dart
  784 +ValueBuilder<bool>(
  785 + initialValue: false,
  786 + builder: (value, updateFn) => Switch(
  787 + value: value,
  788 + onChanged: updateFn, // same signature! you could use ( newValue ) => updateFn( newValue )
  789 + ),
  790 + // if you need to call something outside the builder method.
  791 + onUpdate: (value) => print("Value updated: $value"),
  792 + onDispose: () => print("Widget unmounted"),
  793 +),
  794 +```
  795 +
  796 +#### ObxValue
  797 +
  798 +Similar to [`ValueBuilder`](#valuebuilder), but this is the Reactive version, you pass a Rx instance (remember the magical .obs?) and
  799 +updates automatically... isn't it awesome?
  800 +
  801 +```dart
  802 +ObxValue((data) => Switch(
  803 + value: data.value,
  804 + onChanged: data, // Rx has a _callable_ function! You could use (flag) => data.value = flag,
  805 + ),
  806 + false.obs,
  807 +),
  808 +```
  809 +
  810 +## Useful tips
  811 +
  812 +`.obs`ervables (also known as _Rx_ Types) have a wide variety of internal methods and operators.
  813 +
  814 +> Is very common to _believe_ that a property with `.obs` **IS** the actual value... but make no mistake!
  815 +> We avoid the Type declaration of the variable, because Dart's compiler is smart enough, and the code
  816 +> looks cleaner, but:
  817 +
  818 +```dart
  819 +var message = 'Hello world'.obs;
  820 +print( 'Message "$message" has Type ${message.runtimeType}');
  821 +```
  822 +
  823 +Even if `message` _prints_ the actual String value, the Type is **RxString**!
  824 +
  825 +So, you can't do `message.substring( 0, 4 )`.
  826 +You have to access the real `value` inside the _observable_:
  827 +The most "used way" is `.value`, but, did you know that you can also use...
  828 +
  829 +```dart
  830 +final name = 'GetX'.obs;
  831 +// only "updates" the stream, if the value is different from the current one.
  832 +name.value = 'Hey';
  833 +
  834 +// All Rx properties are "callable" and returns the new value.
  835 +// but this approach does not accepts `null`, the UI will not rebuild.
  836 +name('Hello');
  837 +
  838 +// is like a getter, prints 'Hello'.
  839 +name() ;
  840 +
  841 +/// numbers:
  842 +
  843 +final count = 0.obs;
  844 +
  845 +// You can use all non mutable operations from num primitives!
  846 +count + 1;
  847 +
  848 +// Watch out! this is only valid if `count` is not final, but var
  849 +count += 1;
  850 +
  851 +// You can also compare against values:
  852 +count > 2;
  853 +
  854 +/// booleans:
  855 +
  856 +final flag = false.obs;
  857 +
  858 +// switches the value between true/false
  859 +flag.toggle();
  860 +
  861 +
  862 +/// all types:
  863 +
  864 +// Sets the `value` to null.
  865 +flag.nil();
  866 +
  867 +// All toString(), toJson() operations are passed down to the `value`
  868 +print( count ); // calls `toString()` inside for RxInt
  869 +
  870 +final abc = [0,1,2].obs;
  871 +// Converts the value to a json Array, prints RxList
  872 +// Json is supported by all Rx types!
  873 +print('json: ${jsonEncode(abc)}, type: ${abc.runtimeType}');
  874 +
  875 +// RxMap, RxList and RxSet are special Rx types, that extends their native types.
  876 +// but you can work with a List as a regular list, although is reactive!
  877 +abc.add(12); // pushes 12 to the list, and UPDATES the stream.
  878 +abc[3]; // like Lists, reads the index 3.
  879 +
  880 +
  881 +// equality works with the Rx and the value, but hashCode is always taken from the value
  882 +final number = 12.obs;
  883 +print( number == 12 ); // prints > true
  884 +
  885 +/// Custom Rx Models:
  886 +
  887 +// toJson(), toString() are deferred to the child, so you can implement override on them, and print() the observable directly.
  888 +
  889 +class User {
  890 + String name, last;
  891 + int age;
  892 + User({this.name, this.last, this.age});
  893 +
  894 + @override
  895 + String toString() => '$name $last, $age years old';
  896 +}
  897 +
  898 +final user = User(name: 'John', last: 'Doe', age: 33).obs;
  899 +
  900 +// `user` is "reactive", but the properties inside ARE NOT!
  901 +// So, if we change some variable inside of it...
  902 +user.value.name = 'Roi';
  903 +// The widget will not rebuild!,
  904 +// `Rx` don't have any clue when you change something inside user.
  905 +// So, for custom classes, we need to manually "notify" the change.
  906 +user.refresh();
  907 +
  908 +// or we can use the `update()` method!
  909 +user.update((value){
  910 + value.name='Roi';
  911 +});
  912 +
  913 +print( user );
  914 +```
  915 +## StateMixin
  916 +
  917 +Another way to handle your `UI` state is use the `StateMixin<T>` .
  918 +To implement it, use the `with` to add the `StateMixin<T>`
  919 +to your controller which allows a T model.
  920 +
  921 +``` dart
  922 +class Controller extends GetController with StateMixin<User>{}
  923 +```
  924 +
  925 +The `change()` method change the State whenever we want.
  926 +Just pass the data and the status in this way:
  927 +
  928 +```dart
  929 +change(data, status: RxStatus.success());
  930 +```
  931 +
  932 +RxStatus allow these status:
  933 +
  934 +``` dart
  935 +RxStatus.loading();
  936 +RxStatus.success();
  937 +RxStatus.empty();
  938 +RxStatus.error('message');
  939 +```
  940 +
  941 +To represent it in the UI, use:
  942 +
  943 +```dart
  944 +class OtherClass extends GetView<Controller> {
  945 + @override
  946 + Widget build(BuildContext context) {
  947 + return Scaffold(
  948 +
  949 + body: controller.obx(
  950 + (state)=>Text(state.name),
  951 +
  952 + // here you can put your custom loading indicator, but
  953 + // by default would be Center(child:CircularProgressIndicator())
  954 + onLoading: CustomLoadingIndicator(),
  955 + onEmpty: Text('No data found'),
  956 +
  957 + // here also you can set your own error widget, but by
  958 + // default will be an Center(child:Text(error))
  959 + onError: (error)=>Text(error),
  960 + ),
  961 + );
  962 +}
  963 +```
  964 +
  965 +#### GetView
  966 +
  967 +I love this Widget, is so simple, yet, so useful!
  968 +
  969 +Is a `const Stateless` Widget that has a getter `controller` for a registered `Controller`, that's all.
  970 +
  971 +```dart
  972 + class AwesomeController extends GetController {
  973 + final String title = 'My Awesome View';
  974 + }
  975 +
  976 + // ALWAYS remember to pass the `Type` you used to register your controller!
  977 + class AwesomeView extends GetView<AwesomeController> {
  978 + @override
  979 + Widget build(BuildContext context) {
  980 + return Container(
  981 + padding: EdgeInsets.all(20),
  982 + child: Text(controller.title), // just call `controller.something`
  983 + );
  984 + }
  985 + }
  986 +```
  987 +
  988 +#### GetResponsiveView
  989 +
  990 +Extend this widget to build responsive view.
  991 +this widget contains the `screen` property that have all
  992 +information about the screen size and type.
  993 +
  994 +##### How to use it
  995 +
  996 +You have two options to build it.
  997 +
  998 +- with `builder` method you return the widget to build.
  999 +- with methods `desktop`, `tablet`,`phone`, `watch`. the specific
  1000 + method will be built when the screen type matches the method
  1001 + when the screen is [ScreenType.Tablet] the `tablet` method
  1002 + will be exuded and so on.
  1003 + **Note:** If you use this method please set the property `alwaysUseBuilder` to `false`
  1004 +
  1005 +With `settings` property you can set the width limit for the screen types.
  1006 +
  1007 +![example](https://github.com/SchabanBo/get_page_example/blob/master/docs/Example.gif?raw=true)
  1008 +Code to this screen
  1009 +[code](https://github.com/SchabanBo/get_page_example/blob/master/lib/pages/responsive_example/responsive_view.dart)
  1010 +
  1011 +#### GetWidget
  1012 +
  1013 +Most people have no idea about this Widget, or totally confuse the usage of it.
  1014 +The use case is very rare, but very specific: It `caches` a Controller.
  1015 +Because of the _cache_, can't be a `const Stateless`.
  1016 +
  1017 +> So, when do you need to "cache" a Controller?
  1018 +
  1019 +If you use, another "not so common" feature of **GetX**: `Get.create()`.
  1020 +
  1021 +`Get.create(()=>Controller())` will generate a new `Controller` each time you call
  1022 +`Get.find<Controller>()`,
  1023 +
  1024 +That's where `GetWidget` shines... as you can use it, for example,
  1025 +to keep a list of Todo items. So, if the widget gets "rebuilt", it will keep the same controller instance.
  1026 +
  1027 +#### GetxService
  1028 +
  1029 +This class is like a `GetxController`, it shares the same lifecycle ( `onInit()`, `onReady()`, `onClose()`).
  1030 +But has no "logic" inside of it. It just notifies **GetX** Dependency Injection system, that this subclass
  1031 +**can not** be removed from memory.
  1032 +
  1033 +So is super useful to keep your "Services" always reachable and active with `Get.find()`. Like:
  1034 +`ApiService`, `StorageService`, `CacheService`.
  1035 +
  1036 +```dart
  1037 +Future<void> main() async {
  1038 + await initServices(); /// AWAIT SERVICES INITIALIZATION.
  1039 + runApp(SomeApp());
  1040 +}
  1041 +
  1042 +/// Is a smart move to make your Services intiialize before you run the Flutter app.
  1043 +/// as you can control the execution flow (maybe you need to load some Theme configuration,
  1044 +/// apiKey, language defined by the User... so load SettingService before running ApiService.
  1045 +/// so GetMaterialApp() doesnt have to rebuild, and takes the values directly.
  1046 +void initServices() async {
  1047 + print('starting services ...');
  1048 + /// Here is where you put get_storage, hive, shared_pref initialization.
  1049 + /// or moor connection, or whatever that's async.
  1050 + await Get.putAsync(() => DbService().init());
  1051 + await Get.putAsync(SettingsService()).init();
  1052 + print('All services started...');
  1053 +}
  1054 +
  1055 +class DbService extends GetxService {
  1056 + Future<DbService> init() async {
  1057 + print('$runtimeType delays 2 sec');
  1058 + await 2.delay();
  1059 + print('$runtimeType ready!');
  1060 + return this;
  1061 + }
  1062 +}
  1063 +
  1064 +class SettingsService extends GetxService {
  1065 + void init() async {
  1066 + print('$runtimeType delays 1 sec');
  1067 + await 1.delay();
  1068 + print('$runtimeType ready!');
  1069 + }
  1070 +}
  1071 +
  1072 +```
  1073 +
  1074 +The only way to actually delete a `GetxService`, is with `Get.reset()` which is like a
  1075 +"Hot Reboot" of your app. So remember, if you need absolute persistence of a class instance during the
  1076 +lifetime of your app, use `GetxService`.
  1077 +
  1078 +
  1079 +### Tests
  1080 +
  1081 +You can test your controllers like any other class, including their lifecycles:
  1082 +
  1083 +```dart
  1084 +class Controller extends GetxController {
  1085 + @override
  1086 + void onInit() {
  1087 + super.onInit();
  1088 + //Change value to name2
  1089 + name.value = 'name2';
  1090 + }
  1091 +
  1092 + @override
  1093 + void onClose() {
  1094 + name.value = '';
  1095 + super.onClose();
  1096 + }
  1097 +
  1098 + final name = 'name1'.obs;
  1099 +
  1100 + void changeName() => name.value = 'name3';
  1101 +}
  1102 +
  1103 +void main() {
  1104 + test('''
  1105 +Test the state of the reactive variable "name" across all of its lifecycles''',
  1106 + () {
  1107 + /// You can test the controller without the lifecycle,
  1108 + /// but it's not recommended unless you're not using
  1109 + /// GetX dependency injection
  1110 + final controller = Controller();
  1111 + expect(controller.name.value, 'name1');
  1112 +
  1113 + /// If you are using it, you can test everything,
  1114 + /// including the state of the application after each lifecycle.
  1115 + Get.put(controller); // onInit was called
  1116 + expect(controller.name.value, 'name2');
  1117 +
  1118 + /// Test your functions
  1119 + controller.changeName();
  1120 + expect(controller.name.value, 'name3');
  1121 +
  1122 + /// onClose was called
  1123 + Get.delete<Controller>();
  1124 +
  1125 + expect(controller.name.value, '');
  1126 + });
  1127 +}
  1128 +```
  1129 +
  1130 +#### Tips
  1131 +
  1132 +##### Mockito or mocktail
  1133 +If you need to mock your GetxController/GetxService, you should extend GetxController, and mixin it with Mock, that way
  1134 +
  1135 +```dart
  1136 +class NotificationServiceMock extends GetxService with Mock implements NotificationService {}
  1137 +```
  1138 +
  1139 +##### Using Get.reset()
  1140 +If you are testing widgets, or test groups, use Get.reset at the end of your test or in tearDown to reset all settings from your previous test.
  1141 +
  1142 +##### Get.testMode
  1143 +if you are using your navigation in your controllers, use `Get.testMode = true` at the beginning of your main.
  1144 +
  1145 +
  1146 +# Breaking changes from 2.0
  1147 +
  1148 +1- Rx types:
  1149 +
  1150 +| Before | After |
  1151 +| ------- | ---------- |
  1152 +| StringX | `RxString` |
  1153 +| IntX | `RxInt` |
  1154 +| MapX | `RxMap` |
  1155 +| ListX | `RxList` |
  1156 +| NumX | `RxNum` |
  1157 +| DoubleX | `RxDouble` |
  1158 +
  1159 +RxController and GetBuilder now have merged, you no longer need to memorize which controller you want to use, just use GetxController, it will work for simple state management and for reactive as well.
  1160 +
  1161 +2- NamedRoutes
  1162 +Before:
  1163 +
  1164 +```dart
  1165 +GetMaterialApp(
  1166 + namedRoutes: {
  1167 + '/': GetRoute(page: Home()),
  1168 + }
  1169 +)
  1170 +```
  1171 +
  1172 +Now:
  1173 +
  1174 +```dart
  1175 +GetMaterialApp(
  1176 + getPages: [
  1177 + GetPage(name: '/', page: () => Home()),
  1178 + ]
  1179 +)
  1180 +```
  1181 +
  1182 +Why this change?
  1183 +Often, it may be necessary to decide which page will be displayed from a parameter, or a login token, the previous approach was inflexible, as it did not allow this.
  1184 +Inserting the page into a function has significantly reduced the RAM consumption, since the routes will not be allocated in memory since the app was started, and it also allowed to do this type of approach:
  1185 +
  1186 +```dart
  1187 +
  1188 +GetStorage box = GetStorage();
  1189 +
  1190 +GetMaterialApp(
  1191 + getPages: [
  1192 + GetPage(name: '/', page:(){
  1193 + return box.hasData('token') ? Home() : Login();
  1194 + })
  1195 + ]
  1196 +)
  1197 +```
  1198 +
  1199 +# Why Getx?
  1200 +
  1201 +1- Many times after a Flutter update, many of your packages will break. Sometimes compilation errors happen, errors often appear that there are still no answers about, and the developer needs to know where the error came from, track the error, only then try to open an issue in the corresponding repository, and see its problem solved. Get centralizes the main resources for development (State, dependency and route management), allowing you to add a single package to your pubspec, and start working. After a Flutter update, the only thing you need to do is update the Get dependency, and get to work. Get also resolves compatibility issues. How many times a version of a package is not compatible with the version of another, because one uses a dependency in one version, and the other in another version? This is also not a concern using Get, as everything is in the same package and is fully compatible.
  1202 +
  1203 +2- Flutter is easy, Flutter is incredible, but Flutter still has some boilerplate that may be unwanted for most developers, such as `Navigator.of(context).push (context, builder [...]`. Get simplifies development. Instead of writing 8 lines of code to just call a route, you can just do it: `Get.to(Home())` and you're done, you'll go to the next page. Dynamic web urls are a really painful thing to do with Flutter currently, and that with GetX is stupidly simple. Managing states in Flutter, and managing dependencies is also something that generates a lot of discussion, as there are hundreds of patterns in the pub. But there is nothing as easy as adding a ".obs" at the end of your variable, and place your widget inside an Obx, and that's it, all updates to that variable will be automatically updated on the screen.
  1204 +
  1205 +3- Ease without worrying about performance. Flutter's performance is already amazing, but imagine that you use a state manager, and a locator to distribute your blocs/stores/controllers/ etc. classes. You will have to manually call the exclusion of that dependency when you don't need it. But have you ever thought of simply using your controller, and when it was no longer being used by anyone, it would simply be deleted from memory? That's what GetX does. With SmartManagement, everything that is not being used is deleted from memory, and you shouldn't have to worry about anything but programming. You will be assured that you are consuming the minimum necessary resources, without even having created a logic for this.
  1206 +
  1207 +4- Actual decoupling. You may have heard the concept "separate the view from the business logic". This is not a peculiarity of BLoC, MVC, MVVM, and any other standard on the market has this concept. However, this concept can often be mitigated in Flutter due to the use of context.
  1208 +If you need context to find an InheritedWidget, you need it in the view, or pass the context by parameter. I particularly find this solution very ugly, and to work in teams we will always have a dependence on View's business logic. Getx is unorthodox with the standard approach, and while it does not completely ban the use of StatefulWidgets, InitState, etc., it always has a similar approach that can be cleaner. Controllers have life cycles, and when you need to make an APIREST request for example, you don't depend on anything in the view. You can use onInit to initiate the http call, and when the data arrives, the variables will be populated. As GetX is fully reactive (really, and works under streams), once the items are filled, all widgets that use that variable will be automatically updated in the view. This allows people with UI expertise to work only with widgets, and not have to send anything to business logic other than user events (like clicking a button), while people working with business logic will be free to create and test the business logic separately.