Nipodemos

Separating documentation in multiple files

@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 *Languages: English (this file), [Brazilian Portuguese](README.pt-br.md).* 3 *Languages: English (this file), [Brazilian Portuguese](README.pt-br.md).*
4 4
5 -[![pub package](https://img.shields.io/pub/v/get.svg?label=get&color=blue)](https://pub.dev/packages/get) 5 +[![pub package](https://img.shields.io/pub/v/get.svg?label=get&color=blue)](https://pub.dev/packages/get)
6 ![building](https://github.com/jonataslaw/get/workflows/build/badge.svg) 6 ![building](https://github.com/jonataslaw/get/workflows/build/badge.svg)
7 [![Gitter](https://badges.gitter.im/flutter_get/community.svg)](https://gitter.im/flutter_get/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 7 [![Gitter](https://badges.gitter.im/flutter_get/community.svg)](https://gitter.im/flutter_get/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
8 <a href="https://github.com/Solido/awesome-flutter"> 8 <a href="https://github.com/Solido/awesome-flutter">
@@ -12,7 +12,20 @@ @@ -12,7 +12,20 @@
12 <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> 12 <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
13 [![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-) 13 [![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
14 <!-- ALL-CONTRIBUTORS-BADGE:END --> 14 <!-- ALL-CONTRIBUTORS-BADGE:END -->
  15 +- [About Get](#about-get)
  16 +- [The Three pillars](#the-three-pillars)
  17 + - [State management](#state-management)
  18 + - [Route management](#route-management)
  19 + - [Dependency management](#dependency-management)
  20 +- [How to contribute](#how-to-contribute)
  21 +- [Utils](#utils)
  22 + - [Change Theme](#change-theme)
  23 + - [Other Advanced APIs and Manual configurations](#other-advanced-apis-and-manual-configurations)
  24 + - [Optional Global Settings](#optional-global-settings)
  25 +- [Breaking changes from 2.0](#breaking-changes-from-20)
  26 +- [Why I made this package](#why-i-made-this-package)
15 27
  28 +# About Get
16 29
17 - Get is an extra-light and powerful solution for Flutter. It combines high performance state management, intelligent dependency injection, and route management in a quick and practical way. 30 - Get is an extra-light and powerful solution for Flutter. It combines high performance state management, intelligent dependency injection, and route management in a quick and practical way.
18 - Get is not for everyone, its focus is (performance) on the minimum consumption of resources ([look the benchmarks](https://github.com/jonataslaw/benchmarks)), (productivity) using an easy and pleasant syntax and (organization) allowing the total decoupling of the View from the business logic. 31 - Get is not for everyone, its focus is (performance) on the minimum consumption of resources ([look the benchmarks](https://github.com/jonataslaw/benchmarks)), (productivity) using an easy and pleasant syntax and (organization) allowing the total decoupling of the View from the business logic.
@@ -20,26 +33,35 @@ @@ -20,26 +33,35 @@
20 33
21 **Get makes your development productive, but want to make it even more productive? Add the extension [Get extension to VSCode](https://marketplace.visualstudio.com/items?itemName=get-snippets.get-snippets) to your VSCode** 34 **Get makes your development productive, but want to make it even more productive? Add the extension [Get extension to VSCode](https://marketplace.visualstudio.com/items?itemName=get-snippets.get-snippets) to your VSCode**
22 35
  36 +# The Three pillars
  37 +
  38 +## State management
  39 +
  40 +**See an more in-depth explanation of state management [here](./docs/state_management.md). There you will see more examples and also the differente between the simple stage manager and the reactive state manager**
23 41
24 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. 42 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.
25 43
26 -- Step 1: 44 +- Step 1:
27 Add "Get" before your materialApp, turning it into GetMaterialApp 45 Add "Get" before your materialApp, turning it into GetMaterialApp
  46 +
28 ```dart 47 ```dart
29 void main() => runApp(GetMaterialApp(home: Home())); 48 void main() => runApp(GetMaterialApp(home: Home()));
30 ``` 49 ```
  50 +
31 - Step 2: 51 - Step 2:
32 Create your business logic class and place all variables, methods and controllers inside it. 52 Create your business logic class and place all variables, methods and controllers inside it.
33 You can make any variable observable using a simple ".obs". 53 You can make any variable observable using a simple ".obs".
34 54
35 ```dart 55 ```dart
36 class Controller extends GetxController{ 56 class Controller extends GetxController{
37 - var count = 0.obs; 57 + var count = 0.obs;
38 increment() => count.value++; 58 increment() => count.value++;
39 } 59 }
40 ``` 60 ```
  61 +
41 - Step 3: 62 - Step 3:
42 Create your View, use StatelessWidget and save some RAM, with Get you may no longer need to use StatefulWidget. 63 Create your View, use StatelessWidget and save some RAM, with Get you may no longer need to use StatefulWidget.
  64 +
43 ```dart 65 ```dart
44 class Home extends StatelessWidget { 66 class Home extends StatelessWidget {
45 67
@@ -72,69 +94,13 @@ class Other extends StatelessWidget { @@ -72,69 +94,13 @@ class Other extends StatelessWidget {
72 94
73 This is a simple project but it already makes clear how powerful Get is. As your project grows, this difference will become more significant. Get was designed to work with teams, but it makes the job of an individual developer simple. 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! 95 This is a simple project but it already makes clear how powerful Get is. As your project grows, this difference will become more significant. Get was designed to work with teams, but it makes the job of an individual developer simple. 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!
74 96
75 -- [Route Management](#route-management)  
76 - - [How to use?](#how-to-use)  
77 - - [Navigation without named routes](#navigation-without-named-routes)  
78 - - [Navigation with named routes](#navigation-with-named-routes)  
79 - - [Send data to named Routes:](#send-data-to-named-routes)  
80 - - [Dynamic urls links](#dynamic-urls-links)  
81 - - [Middleware](#middleware)  
82 - - [Navigation without context](#navigation-without-context)  
83 - - [SnackBars](#snackbars)  
84 - - [Dialogs](#dialogs)  
85 - - [BottomSheets](#bottomsheets)  
86 - - [Nested Navigation](#nested-navigation)  
87 -- [State Management](#state-management)  
88 - - [Simple State Manager](#simple-state-manager)  
89 - - [Advantages](#advantages)  
90 - - [Usage](#usage)  
91 - - [How it handles controllers](#how-it-handles-controllers)  
92 - - [You won't need StatefulWidgets anymore](#you-wont-need-statefulwidgets-anymore)  
93 - - [Why it exists](#why-it-exists)  
94 - - [Other ways of using it](#other-ways-of-using-it)  
95 - - [Unique IDs](#unique-ids)  
96 - - [Reactive State Manager](#reactive-state-manager)  
97 - - [Advantages](#advantages-1)  
98 - - [Usage](#usage-1)  
99 - - [Where .obs can be used](#where-obs-can-be-used)  
100 - - [Note about Lists](#note-about-lists)  
101 - - [Why i have to use .value?](#why-i-have-to-use-value)  
102 - - [Obx()](#obx)  
103 - - [Workers:](#workers)  
104 - - [Mixing the two state managers](#mixing-the-two-state-managers)  
105 - - [GetBuilder vs GetX && Obx vs MixinBuilder](#getbuilder-vs-getx-vs-obx-vs-mixinbuilder)  
106 -- [Dependency Management](#dependency-management)  
107 - - [Simple Instance Manager](#simple-instance-manager)  
108 - - [Bindings](#bindings)  
109 - - [How to use](#how-to-use-1)  
110 - - [SmartManagement](#smartmanagement)  
111 -- [Utils](#utils)  
112 - - [Change Theme](#change-theme)  
113 - - [Other Advanced APIs and Manual configurations](#other-advanced-apis-and-manual-configurations)  
114 - - [Optional Global Settings](#optional-global-settings)  
115 -- [Breaking changes from 2.0](#breaking-changes-from-2.0) 97 +## Route management
116 98
117 -*Want to contribute to the project? We will be proud to highlight you as one of our collaborators. Here are some points where you can contribute and make Get (and Flutter) even better.* 99 +**See a more in-depth explanation of route management [here](./docs/route_management.md)**
118 100
119 -- Helping to translate the readme into other languages.  
120 -- Adding documentation to the readme (not even half of Get's functions have been documented yet).  
121 -- Write articles or make videos teaching how to use Get (they will be inserted in the Readme and in the future in our Wiki).  
122 -- Offering PRs for code/tests.  
123 -- Including new functions.  
124 -  
125 -# Route Management  
126 -  
127 -Any contribution is welcome!  
128 -  
129 -## How to use? 101 +If you are going to use routes/snackbars/dialogs/bottomsheets without context, GetX is excellent for you too, just see it:
130 102
131 -Add this to your pubspec.yaml file:  
132 -  
133 -```  
134 -dependencies:  
135 - get:  
136 -```  
137 -If you are going to use routes/snackbars/dialogs/bottomsheets without context, or use the high-level Get APIs, you need to simply add "Get" before your MaterialApp, turning it into GetMaterialApp and enjoy! 103 +Add "Get" before your MaterialApp, turning it into GetMaterialApp
138 104
139 ```dart 105 ```dart
140 GetMaterialApp( // Before: MaterialApp( 106 GetMaterialApp( // Before: MaterialApp(
@@ -142,7 +108,6 @@ GetMaterialApp( // Before: MaterialApp( @@ -142,7 +108,6 @@ GetMaterialApp( // Before: MaterialApp(
142 ) 108 )
143 ``` 109 ```
144 110
145 -## Navigation without named routes  
146 To navigate to a new screen: 111 To navigate to a new screen:
147 112
148 ```dart 113 ```dart
@@ -168,1113 +133,37 @@ Get.offAll(NextScreen()); @@ -168,1113 +133,37 @@ Get.offAll(NextScreen());
168 ``` 133 ```
169 134
170 To navigate to the next route, and receive or update data as soon as you return from it: 135 To navigate to the next route, and receive or update data as soon as you return from it:
171 -```dart  
172 -var data = await Get.to(Payment());  
173 -```  
174 -on other screen, send a data for previous route:  
175 -  
176 -```dart  
177 -Get.back(result: 'success');  
178 -```  
179 -And use it:  
180 -  
181 -ex:  
182 -```dart  
183 -if(data == 'success') madeAnything();  
184 -```  
185 -  
186 -Don't you want to learn our syntax?  
187 -Just change the Navigator (uppercase) to navigator (lowercase), and you will have all the functions of the standard navigation, without having to use context  
188 -Example:  
189 -  
190 -```dart  
191 -  
192 -// Default Flutter navigator  
193 -Navigator.of(context).push(  
194 - context,  
195 - MaterialPageRoute(  
196 - builder: (BuildContext context) {  
197 - return HomePage();  
198 - },  
199 - ),  
200 -);  
201 -  
202 -// Get using Flutter syntax without needing context  
203 -navigator.push(  
204 - MaterialPageRoute(  
205 - builder: (_) {  
206 - return HomePage();  
207 - },  
208 - ),  
209 -);  
210 -  
211 -// Get syntax (It is much better, but you have the right to disagree)  
212 -Get.to(HomePage());  
213 -  
214 -  
215 -```  
216 -  
217 -## Navigation with named routes  
218 -- If you prefer to navigate by namedRoutes, Get also supports this.  
219 -  
220 -To navigate to nextScreen  
221 -```dart  
222 -Get.toNamed("/NextScreen");  
223 -```  
224 -To navigate and remove the previous screen from the tree.  
225 -```dart  
226 -Get.offNamed("/NextScreen");  
227 -```  
228 -To navigate and remove all previous screens from the tree.  
229 -```dart  
230 -Get.offAllNamed("/NextScreen");  
231 -```  
232 -  
233 -To define routes, use GetMaterialApp:  
234 -  
235 -```dart  
236 -void main() {  
237 - runApp(  
238 - GetMaterialApp(  
239 - initialRoute: '/',  
240 - getPages: [  
241 - GetPage(name: '/', page: () => MyHomePage()),  
242 - GetPage(name: '/second', page: () => Second()),  
243 - GetPage(  
244 - name: '/third',  
245 - page: () => Third(),  
246 - transition: Transition.zoom  
247 - ),  
248 - ],  
249 - )  
250 - );  
251 -}  
252 -```  
253 -  
254 -### Send data to named Routes:  
255 -  
256 -Just send what you want for arguments. Get accepts anything here, whether it is a String, a Map, a List, or even a class instance.  
257 -```dart  
258 -Get.toNamed("/NextScreen", arguments: 'Get is the best');  
259 -```  
260 -on your class or controller:  
261 -  
262 -```dart  
263 -print(Get.arguments);  
264 -//print out: Get is the best  
265 -```  
266 -  
267 -### Dynamic urls links  
268 -Get offer advanced dynamic urls just like on the Web. Web developers have probably already wanted this feature on Flutter, and most likely have seen a package promise this feature and deliver a totally different syntax than a URL would have on web, but Get also solves that.  
269 -  
270 -```dart  
271 -Get.offAllNamed("/NextScreen?device=phone&id=354&name=Enzo");  
272 -```  
273 -on your controller/bloc/stateful/stateless class:  
274 -  
275 -```dart  
276 -print(Get.parameters['id']);  
277 -// out: 354  
278 -print(Get.parameters['name']);  
279 -// out: Enzo  
280 -```  
281 -  
282 -You can also receive NamedParameters with Get easily:  
283 -  
284 -```dart  
285 -void main() {  
286 - runApp(  
287 - GetMaterialApp(  
288 - initialRoute: '/',  
289 - getPages: [  
290 - GetPage(  
291 - name: '/',  
292 - page: () => MyHomePage(),  
293 - ),  
294 - GetPage(  
295 - name: '/profile/',  
296 - page: () => MyProfile(),  
297 - ),  
298 - //You can define a different page for routes with arguments, and another without arguments, but for that you must use the slash '/' on the route that will not receive arguments as above.  
299 - GetPage(  
300 - name: '/profile/:user',  
301 - page: () => UserProfile(),  
302 - ),  
303 - GetPage(  
304 - name: '/third',  
305 - page: () => Third(),  
306 - transition: Transition.cupertino  
307 - ),  
308 - ],  
309 - )  
310 - );  
311 -}  
312 -```  
313 -Send data on route name  
314 -```dart  
315 -Get.toNamed("/second/34954");  
316 -```  
317 -  
318 -On second screen take the data by parameter  
319 -  
320 -```dart  
321 -print(Get.parameters['user']);  
322 -// out: 34954  
323 -```  
324 -  
325 -And now, all you need to do is use Get.toNamed() to navigate your named routes, without any context (you can call your routes directly from your BLoC or Controller class), and when your app is compiled to the web, your routes will appear in the url <3  
326 -  
327 -  
328 -### Middleware  
329 -If you want listen Get events to trigger actions, you can to use routingCallback to it  
330 -```dart  
331 -GetMaterialApp(  
332 - routingCallback: (routing) {  
333 - if(routing.current == '/second'){  
334 - openAds();  
335 - }  
336 - }  
337 -)  
338 -```  
339 -If you are not using GetMaterialApp, you can use the manual API to attach Middleware observer.  
340 -  
341 -```dart  
342 -void main() {  
343 - runApp(  
344 - MaterialApp(  
345 - onGenerateRoute: Router.generateRoute,  
346 - initialRoute: "/",  
347 - navigatorKey: Get.key,  
348 - navigatorObservers: [  
349 - GetObserver(MiddleWare.observer), // HERE !!!  
350 - ],  
351 - ),  
352 - );  
353 -}  
354 -```  
355 -Create a MiddleWare class  
356 -  
357 -```dart  
358 -class MiddleWare {  
359 - static observer(Routing routing) {  
360 - /// You can listen in addition to the routes, the snackbars, dialogs and bottomsheets on each screen.  
361 - ///If you need to enter any of these 3 events directly here,  
362 - ///you must specify that the event is != Than you are trying to do.  
363 - if (routing.current == '/second' && !routing.isSnackbar) {  
364 - Get.snackbar("Hi", "You are on second route");  
365 - } else if (routing.current =='/third'){  
366 - print('last route called');  
367 - }  
368 - }  
369 -}  
370 -```  
371 -  
372 -Now, use Get on your code:  
373 -  
374 -```dart  
375 -class First extends StatelessWidget {  
376 - @override  
377 - Widget build(BuildContext context) {  
378 - return Scaffold(  
379 - appBar: AppBar(  
380 - leading: IconButton(  
381 - icon: Icon(Icons.add),  
382 - onPressed: () {  
383 - Get.snackbar("hi", "i am a modern snackbar");  
384 - },  
385 - ),  
386 - title: Text('First Route'),  
387 - ),  
388 - body: Center(  
389 - child: RaisedButton(  
390 - child: Text('Open route'),  
391 - onPressed: () {  
392 - Get.toNamed("/second");  
393 - },  
394 - ),  
395 - ),  
396 - );  
397 - }  
398 -}  
399 -  
400 -class Second extends StatelessWidget {  
401 - @override  
402 - Widget build(BuildContext context) {  
403 - return Scaffold(  
404 - appBar: AppBar(  
405 - leading: IconButton(  
406 - icon: Icon(Icons.add),  
407 - onPressed: () {  
408 - Get.snackbar("hi", "i am a modern snackbar");  
409 - },  
410 - ),  
411 - title: Text('second Route'),  
412 - ),  
413 - body: Center(  
414 - child: RaisedButton(  
415 - child: Text('Open route'),  
416 - onPressed: () {  
417 - Get.toNamed("/third");  
418 - },  
419 - ),  
420 - ),  
421 - );  
422 - }  
423 -}  
424 -  
425 -class Third extends StatelessWidget {  
426 - @override  
427 - Widget build(BuildContext context) {  
428 - return Scaffold(  
429 - appBar: AppBar(  
430 - title: Text("Third Route"),  
431 - ),  
432 - body: Center(  
433 - child: RaisedButton(  
434 - onPressed: () {  
435 - Get.back();  
436 - },  
437 - child: Text('Go back!'),  
438 - ),  
439 - ),  
440 - );  
441 - }  
442 -}  
443 -```  
444 -## Navigation without context  
445 -  
446 -### SnackBars  
447 -  
448 -To have a simple SnackBar with Flutter, you must get the context of Scaffold, or you must use a GlobalKey attached to your Scaffold  
449 -  
450 -```dart  
451 -final snackBar = SnackBar(  
452 - content: Text('Hi!'),  
453 - action: SnackBarAction(  
454 - label: 'I am a old and ugly snackbar :(',  
455 - onPressed: (){}  
456 - ),  
457 -);  
458 -// Find the Scaffold in the widget tree and use  
459 -// it to show a SnackBar.  
460 -Scaffold.of(context).showSnackBar(snackBar);  
461 -```  
462 -  
463 -With Get:  
464 -  
465 -```dart  
466 -Get.snackbar('Hi', 'i am a modern snackbar');  
467 -```  
468 -  
469 -With Get, all you have to do is call your Get.snackbar from anywhere in your code or customize it however you want!  
470 -  
471 -```dart  
472 -Get.snackbar(  
473 - "Hey i'm a Get SnackBar!", // title  
474 - "It's unbelievable! I'm using SnackBar without context, without boilerplate, without Scaffold, it is something truly amazing!", // message  
475 - icon: Icon(Icons.alarm),  
476 - shouldIconPulse: true,  
477 - onTap:(){},  
478 - barBlur: 20,  
479 - isDismissible: true,  
480 - duration: Duration(seconds: 3),  
481 -);  
482 -  
483 -  
484 - ////////// ALL FEATURES //////////  
485 - // Color colorText,  
486 - // Duration duration,  
487 - // SnackPosition snackPosition,  
488 - // Widget titleText,  
489 - // Widget messageText,  
490 - // bool instantInit,  
491 - // Widget icon,  
492 - // bool shouldIconPulse,  
493 - // double maxWidth,  
494 - // EdgeInsets margin,  
495 - // EdgeInsets padding,  
496 - // double borderRadius,  
497 - // Color borderColor,  
498 - // double borderWidth,  
499 - // Color backgroundColor,  
500 - // Color leftBarIndicatorColor,  
501 - // List<BoxShadow> boxShadows,  
502 - // Gradient backgroundGradient,  
503 - // FlatButton mainButton,  
504 - // OnTap onTap,  
505 - // bool isDismissible,  
506 - // bool showProgressIndicator,  
507 - // AnimationController progressIndicatorController,  
508 - // Color progressIndicatorBackgroundColor,  
509 - // Animation<Color> progressIndicatorValueColor,  
510 - // SnackStyle snackStyle,  
511 - // Curve forwardAnimationCurve,  
512 - // Curve reverseAnimationCurve,  
513 - // Duration animationDuration,  
514 - // double barBlur,  
515 - // double overlayBlur,  
516 - // Color overlayColor,  
517 - // Form userInputForm  
518 - ///////////////////////////////////  
519 -```  
520 -If you prefer the traditional snackbar, or want to customize it from scratch, including adding just one line (Get.snackbar makes use of a mandatory title and message), you can use  
521 -`Get.rawSnackbar();` which provides the RAW API on which Get.snackbar was built.  
522 -  
523 -### Dialogs  
524 -  
525 -To open dialog:  
526 -  
527 -```dart  
528 -Get.dialog(YourDialogWidget());  
529 -```  
530 -  
531 -To open default dialog:  
532 -  
533 -```dart  
534 -Get.defaultDialog(  
535 - onConfirm: () => print("Ok"),  
536 - middleText: "Dialog made in 3 lines of code"  
537 -);  
538 -```  
539 -You can also use Get.generalDialog instead of showGeneralDialog.  
540 -  
541 -For all other Flutter dialog widgets, including cupertinos, you can use Get.overlayContext instead of context, and open it anywhere in your code.  
542 -For widgets that don't use Overlay, you can use Get.context.  
543 -These two contexts will work in 99% of cases to replace the context of your UI, except for cases where inheritedWidget is used without a navigation context.  
544 -  
545 -### BottomSheets  
546 -Get.bottomSheet is like showModalBottomSheet, but don't need of context.  
547 -  
548 -```dart  
549 -Get.bottomSheet(  
550 - Container(  
551 - child: Wrap(  
552 - children: <Widget>[  
553 - ListTile(  
554 - leading: Icon(Icons.music_note),  
555 - title: Text('Music'),  
556 - onTap: () => {}  
557 - ),  
558 - ListTile(  
559 - leading: Icon(Icons.videocam),  
560 - title: Text('Video'),  
561 - onTap: () => {},  
562 - ),  
563 - ],  
564 - ),  
565 - );  
566 -);  
567 -```  
568 -  
569 -  
570 -## Nested Navigation  
571 -  
572 -Get made Flutter's nested navigation even easier.  
573 -You don't need the context, and you will find your navigation stack by Id.  
574 -  
575 -- NOTE: Creating parallel navigation stacks can be dangerous. The ideal is not to use NestedNavigators, or to use sparingly. If your project requires it, go ahead, but keep in mind that keeping multiple navigation stacks in memory may not be a good idea for RAM consumption.  
576 -  
577 -See how simple it is:  
578 -```dart  
579 -Navigator(  
580 - key: Get.nestedKey(1), // create a key by index  
581 - initialRoute: '/',  
582 - onGenerateRoute: (settings) {  
583 - if (settings.name == '/') {  
584 - return GetPageRoute(  
585 - page: Scaffold(  
586 - appBar: AppBar(  
587 - title: Text("Main"),  
588 - ),  
589 - body: Center(  
590 - child: FlatButton(  
591 - color: Colors.blue,  
592 - onPressed: () {  
593 - Get.toNamed('/second', id:1); // navigate by your nested route by index  
594 - },  
595 - child: Text("Go to second"),  
596 - ),  
597 - ),  
598 - ),  
599 - );  
600 - } else if (settings.name == '/second') {  
601 - return GetPageRoute(  
602 - page: Center(  
603 - child: Scaffold(  
604 - appBar: AppBar(  
605 - title: Text("Main"),  
606 - ),  
607 - body: Center(  
608 - child: Text("second")  
609 - ),  
610 - ),  
611 - ),  
612 - );  
613 - }  
614 - }  
615 -),  
616 -```  
617 -  
618 -  
619 -# State Management  
620 -  
621 -There are currently several state managers for Flutter. However, most of them involve using ChangeNotifier to update widgets and this is a bad and very bad approach to performance of medium or large applications. You can check in the official Flutter documentation that [ChangeNotifier should be used with 1 or a maximum of 2 listeners](https://api.flutter.dev/flutter/foundation/ChangeNotifier-class.html), making it practically unusable for any application medium or large.  
622 -  
623 -Other state managers are good, but have their nuances:  
624 -- BLoC is very safe and efficient, but it is very complex for beginners, which has kept people from developing with Flutter.  
625 -- MobX is easier than BLoC and reactive, almost perfect, I would say, but you need to use a code generator, that for large applications, reduces productivity, since you will need to drink a lot of coffees until your code is ready again after a `flutter clean` (And this is not MobX's fault, but the codegen which is really slow!).  
626 -- Provider uses InheritedWidget to deliver the same listener, as a way of solving the problem reported above with ChangeNotifier, which implies that any access to its ChangeNotifier class must be within the widget tree because of the context to access o Inherited.  
627 -  
628 -  
629 -Get isn't better or worse than any other state manager, but that you should analyze these points as well as the points below to choose between using Get in pure form (Vanilla), or using it in conjunction with another state manager. Definitely, Get is not the enemy of any other state manager, because Get is a microframework, not just a state manager, and can be used either alone or in conjunction with them.  
630 -  
631 -## Simple State Manager  
632 -  
633 -Get has a state manager that is extremely light and easy, which does not use ChangeNotifier, will meet the need especially for those new to Flutter, and will not cause problems for large applications.  
634 -  
635 -### Advantages  
636 -  
637 -1. Update only the required widgets.  
638 -  
639 -2. Does not use changeNotifier, it is the state manager that uses less memory (close to 0mb).  
640 -  
641 -3. Forget StatefulWidget! With Get you will never need it. With the other state managers, you will probably have to use a StatefulWidget to get the instance of your Provider, BLoC, MobX Controller, etc. But have you ever stopped to think that your appBar, your scaffold, and most of the widgets that are in your class are stateless? So why save the state of an entire class, if you can only save the state of the Widget that is stateful? Get solves that, too. Create a Stateless class, make everything stateless. If you need to update a single component, wrap it with GetBuilder, and its state will be maintained.  
642 -  
643 -4. Organize your project for real! Controllers must not be in your UI, place your TextEditController, or any controller you use within your Controller class.  
644 -  
645 -5. Do you need to trigger an event to update a widget as soon as it is rendered? GetBuilder has the property "initState", just like StatefulWidget, and you can call events from your controller, directly from it, no more events being placed in your initState.  
646 -  
647 -6. Do you need to trigger an action like closing streams, timers and etc? GetBuilder also has the dispose property, where you can call events as soon as that widget is destroyed.  
648 -  
649 -7. Use streams only if necessary. You can use your StreamControllers inside your controller normally, and use StreamBuilder also normally, but remember, a stream reasonably consumes memory, reactive programming is beautiful, but you shouldn't abuse it. 30 streams open simultaneously can be worse than changeNotifier (and changeNotifier is very bad).  
650 -  
651 -8. Update widgets without spending ram for that. Get stores only the GetBuilder creator ID, and updates that GetBuilder when necessary. The memory consumption of the get ID storage in memory is very low even for thousands of GetBuilders. When you create a new GetBuilder, you are actually sharing the state of GetBuilder that has a creator ID. A new state is not created for each GetBuilder, which saves A LOT OF ram for large applications. Basically your application will be entirely Stateless, and the few Widgets that will be Stateful (within GetBuilder) will have a single state, and therefore updating one will update them all. The state is just one.  
652 -  
653 -9. Get is omniscient and in most cases it knows exactly the time to take a controller out of memory. You should not worry about when to dispose of a controller, Get knows the best time to do this.  
654 -  
655 -### Usage  
656 -  
657 -```dart  
658 -// Create controller class and extends GetxController  
659 -class Controller extends GetxController {  
660 - int counter = 0;  
661 - void increment() {  
662 - counter++;  
663 - update(); // use update() to update counter variable on UI when increment be called  
664 - }  
665 -}  
666 -// On your Stateless/Stateful class, use GetBuilder to update Text when increment be called  
667 -GetBuilder<Controller>(  
668 - init: Controller(), // INIT IT ONLY THE FIRST TIME  
669 - builder: (_) => Text(  
670 - '${_.counter}',  
671 - ),  
672 -)  
673 -//Initialize your controller only the first time. The second time you are using ReBuilder for the same controller, do not use it again. Your controller will be automatically removed from memory as soon as the widget that marked it as 'init' is deployed. You don't have to worry about that, Get will do it automatically, just make sure you don't start the same controller twice.  
674 -```  
675 -**Done!**  
676 -- You have already learned how to manage states with Get.  
677 -  
678 -- Note: You may want a larger organization, and not use the init property. For that, you can create a class and extends Bindings class, and within it mention the controllers that will be created within that route. Controllers will not be created at that time, on the contrary, this is just a statement, so that the first time you use a Controller, Get will know where to look. Get will remain lazyLoad, and will continue to dispose Controllers when they are no longer needed. See the pub.dev example to see how it works.  
679 -  
680 -  
681 -If you navigate many routes and need data that was in your previously used controller, you just need to use GetBuilder Again (with no init):  
682 -  
683 -```dart  
684 -class OtherClass extends StatelessWidget {  
685 - @override  
686 - Widget build(BuildContext context) {  
687 - return Scaffold(  
688 - body: Center(  
689 - child: GetBuilder<Controller>(  
690 - builder: (s) => Text('${s.counter}'),  
691 - ),  
692 - ),  
693 - );  
694 - }  
695 -  
696 -```  
697 -If you need to use your controller in many other places, and outside of GetBuilder, just create a get in your controller and have it easily. (or use `Get.find<Controller>()`)  
698 -  
699 -```dart  
700 -class Controller extends GetxController {  
701 -  
702 - /// You do not need that. I recommend using it just for ease of syntax.  
703 - /// with static method: Controller.to.counter();  
704 - /// with no static method: Get.find<Controller>().counter();  
705 - /// There is no difference in performance, nor any side effect of using either syntax. Only one does not need the type, and the other the IDE will autocomplete it.  
706 - static Controller get to => Get.find(); // add this line  
707 -  
708 - int counter = 0;  
709 - void increment() {  
710 - counter++;  
711 - update();  
712 - }  
713 -}  
714 -```  
715 -And then you can access your controller directly, that way:  
716 -```dart  
717 -FloatingActionButton(  
718 - onPressed: () {  
719 - Controller.to.increment(),  
720 - } // This is incredibly simple!  
721 - child: Text("${Controller.to.counter}"),  
722 -),  
723 -```  
724 -When you press FloatingActionButton, all widgets that are listening to the 'counter' variable will be updated automatically.  
725 -  
726 -### How it handles controllers  
727 -Let's say we have this:  
728 -  
729 -`Class a => Class B (has controller X) => Class C (has controller X)`  
730 -  
731 -In class A the controller is not yet in memory, because you have not used it yet (Get is lazyLoad). In class B you used the controller, and it entered memory. In class C you used the same controller as in class B, Get will share the state of controller B with controller C, and the same controller is still in memory. If you close screen C and screen B, Get will automatically take controller X out of memory and free up resources, because Class a is not using the controller. If you navigate to B again, controller X will enter memory again, if instead of going to class C, you return to class A again, Get will take the controller out of memory in the same way. If class C didn't use the controller, and you took class B out of memory, no class would be using controller X and likewise it would be disposed of. The only exception that can mess with Get, is if you remove B from the route unexpectedly, and try to use the controller in C. In this case, the creator ID of the controller that was in B was deleted, and Get was programmed to remove it from memory every controller that has no creator ID. If you intend to do this, add the "autoRemove: false" flag to class B's GetBuilder and use adoptID = true; in class C's GetBuilder.  
732 -  
733 -### You won't need StatefulWidgets anymore  
734 -Using StatefulWidgets means storing the state of entire screens unnecessarily, even because if you need to minimally rebuild a widget, you will embed it in a Consumer/Observer/BlocProvider/GetBuilder/GetX/Obx, which will be another StatefulWidget.  
735 -The StatefulWidget class is a class larger than StatelessWidget, which will allocate more RAM, and this may not make a significant difference between one or two classes, but it will most certainly do when you have 100 of them!  
736 -Unless you need to use a mixin, like TickerProviderStateMixin, it will be totally unnecessary to use a StatefulWidget with Get.  
737 -  
738 -You can call all methods of a StatefulWidget directly from a GetBuilder.  
739 -If you need to call initState() or dispose() method for example, you can call them directly;  
740 -  
741 -```dart  
742 -GetBuilder<Controller>(  
743 - initState: (_) => Controller.to.fetchApi(),  
744 - dispose: (_) => Controller.to.closeStreams(),  
745 - builder: (s) => Text('${s.username}'),  
746 -),  
747 -```  
748 -  
749 -A much better approach than this is to use the onInit() and onClose() method directly from your controller.  
750 -  
751 -```dart  
752 -@override  
753 -void onInit() {  
754 - fetchApi();  
755 - super.onInit();  
756 -}  
757 -```  
758 -  
759 -- NOTE: If you want to start a method at the moment the controller is called for the first time, you DON'T NEED to use constructors for this, in fact, using a performance-oriented package like Get, this borders on bad practice, because it deviates from the logic in which the controllers are created or allocated (if you create an instance of this controller, the constructor will be called immediately, you will be populating a controller before it is even used, you are allocating memory without it being in use, this definitely hurts the principles of this library). The onInit() methods; and onClose(); were created for this, they will be called when the Controller is created, or used for the first time, depending on whether you are using Get.lazyPut or not. If you want, for example, to make a call to your API to populate data, you can forget about the old-fashioned method of initState/dispose, just start your call to the api in onInit, and if you need to execute any command like closing streams, use the onClose() for that.  
760 -  
761 -### Why it exists  
762 -The purpose of this package is precisely to give you a complete solution for navigation of routes, management of dependencies and states, using the least possible dependencies, with a high degree of decoupling. Get engages all high and low level Flutter APIs within itself, to ensure that you work with the least possible coupling. We centralize everything in a single package, to ensure that you don't have any kind of coupling in your project. That way, you can put only widgets in your view, and leave the part of your team that works with the business logic free, to work with the business logic without depending on any element of the View. This provides a much cleaner working environment, so that part of your team works only with widgets, without worrying about sending data to your controller, and part of your team works only with the business logic in its breadth, without depending on no element of the view.  
763 -  
764 -So to simplify this:  
765 -You don't need to call methods in initState and send them by parameter to your controller, nor use your controller constructor for that, you have the onInit() method that is called at the right time for you to start your services.  
766 -You do not need to call the device, you have the onClose() method that will be called at the exact moment when your controller is no longer needed and will be removed from memory. That way, leave views for widgets only, refrain from any kind of business logic from it.  
767 -  
768 -Do not call a dispose method inside GetxController, it will not do anything, remember that the controller is not a Widget, you should not "dispose" it, and it will be automatically and intelligently removed from memory by Get. If you used any stream on it and want to close it, just insert it into the close method. Example:  
769 -  
770 -```dart  
771 -class Controller extends GetxController {  
772 - StreamController<User> user = StreamController<User>();  
773 - StreamController<String> name = StreamController<String>();  
774 -  
775 - /// close stream = onClose method, not dispose.  
776 - @override  
777 - void onClose() {  
778 - user.close();  
779 - name.close();  
780 - super.onClose();  
781 - }  
782 -}  
783 -```  
784 -Controller life cycle:  
785 -- onInit() where it is created.  
786 -- onClose() where it is closed to make any changes in preparation for the delete method  
787 -- deleted: you do not have access to this API because it is literally removing the controller from memory. It is literally deleted, without leaving any trace.  
788 -  
789 -### Other ways of using it  
790 -  
791 -You can use Controller instance directly on GetBuilder value:  
792 136
793 ```dart 137 ```dart
794 -GetBuilder<Controller>(  
795 - init: Controller(),  
796 - builder: (value) => Text(  
797 - '${value.counter}', //here  
798 - ),  
799 -),  
800 -```  
801 -You may also need an instance of your controller outside of your GetBuilder, and you can use these approaches to achieve this:  
802 -  
803 -```dart  
804 -class Controller extends GetxController {  
805 - static Controller get to => Get.find();  
806 -[...]  
807 -}  
808 -// on you view:  
809 -GetBuilder<Controller>(  
810 - init: Controller(), // use it only first time on each controller  
811 - builder: (_) => Text(  
812 - '${Controller.to.counter}', //here  
813 - )  
814 -),  
815 -```  
816 -or  
817 -```dart  
818 -class Controller extends GetxController {  
819 - // static Controller get to => Get.find(); // with no static get  
820 -[...]  
821 -}  
822 -// on stateful/stateless class  
823 -GetBuilder<Controller>(  
824 - init: Controller(), // use it only first time on each controller  
825 - builder: (_) => Text(  
826 - '${Get.find<Controller>().counter}', //here  
827 - ),  
828 -),  
829 -```  
830 -  
831 -- You can use "non-canonical" approaches to do this. If you are using some other dependency manager, like get_it, modular, etc., and just want to deliver the controller instance, you can do this:  
832 -  
833 -```dart  
834 -Controller controller = Controller();  
835 -[...]  
836 -GetBuilder<Controller>(  
837 - init: controller, //here  
838 - builder: (_) => Text(  
839 - '${controller.counter}', // here  
840 - ),  
841 -),  
842 -  
843 -```  
844 -  
845 -### Unique IDs  
846 -If you want to refine a widget's update control with GetBuilder, you can assign them unique IDs:  
847 -```dart  
848 -GetBuilder<Controller>(  
849 - id: 'text'  
850 - init: Controller(), // use it only first time on each controller  
851 - builder: (_) => Text(  
852 - '${Get.find<Controller>().counter}', //here  
853 - ),  
854 -),  
855 -```  
856 -And update it this form:  
857 -```dart  
858 -update(['text']);  
859 -```  
860 -You can also impose conditions for the update:  
861 -  
862 -```dart  
863 -update(['text'], counter < 10);  
864 -```  
865 -  
866 -GetX does this automatically and only reconstructs the widget that uses the exact variable that was changed, if you change a variable to the same as the previous one and that does not imply a change of state , GetX will not rebuild the widget to save memory and CPU cycles (3 is being displayed on the screen, and you change the variable to 3 again. In most state managers, this will cause a new rebuild, but with GetX the widget will only is rebuilt again, if in fact his state has changed).  
867 -  
868 -## Reactive State Manager  
869 -  
870 -Reactive programming can alienate many people because it is said to be complicated. Getx turns reactive programming into something so simple, that it can be used and learned by those who started at that very moment in Flutter. No, you will not need to create StreamControllers. You also won't need to create a StreamBuilder for each variable. You will not need to create a class for each state. You will not need to create a get for an initial value. Reactive programming with Get is as easy as using setState (or even easier!).  
871 -  
872 -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.  
873 -  
874 -This is your count variable:  
875 -```dart  
876 -var name = 'Jonatas Borges';  
877 -```  
878 -To make it observable, you just need to add ".obs" to the end of it:  
879 -```dart  
880 -var name = 'Jonatas Borges'.obs;  
881 -```  
882 -  
883 -This borders on absurdity when it comes to practicality. What did we do under the hood? We created a stream of Strings, assigned the initial value "Jonatas Borges", we warn all widgets that use "Jonatas Borges" that they now belong to this variable, and when it is changed, they will be changed too. This is the magic of Get, that only dart allows us to do this.  
884 -  
885 -Okay, but as we know, a widget can only be changed if it is inside a function, because static classes do not have the power to "auto-change". You will need to create a StreamBuilder, subscribe to listen to this variable, and create a "cascade" of StreamBuilder if you want to change several variables in the same scope, right?  
886 -No, you don't need a StreamBuilder, but you are right about static classes.  
887 -  
888 -Well, in the view we usually have a lot of boilerplate when we want to change a specific widget. With Get you can also forget about this Boilerplate. StreamBuilder? initialValue? builder?  
889 -No, you just need to play this variable inside an Obx widget.  
890 -```dart  
891 -Obx (() => Text (controller.name));  
892 -```  
893 -  
894 -What do you need to memorize? "Obx(() =>" You are just passing that widget through an arrow-function into an Obx. Obx is smart, and will only be changed if the value of name is changed. If name is "John" and you change it to "John", it will not have any changes on the screen, and Obx will simply ignore this change, and will not rebuild the widget, to save resources. Isn't that amazing?  
895 -  
896 -What if I have 5 observable variables within an Obx? It will update when any of them are changed. And if I have 30 variables in a class, when I update one, will it update all variables that are in that class? No, just the specific widget that uses that variable. And if I machine-gun my observable variable 1 billion times with the same value, will I have freeze on the screen for unnecessary reconstructions? No, GetX only updates the screen when the variable changes on the screen, if the screen remains the same, it will not reconstruct anything.  
897 -  
898 -### Advantages  
899 -GetBuilder is aimed precisely at multiple state control. Imagine that you added 30 products to a cart, you click delete one, at the same time that the list is updated, the price is updated and the badge in the shopping cart is updated to a smaller number. This type of approach makes GetBuilder killer, because it groups states and changes them all at once without any "computational logic" for that. GetBuilder was created with this type of situation in mind, since for ephemeral change of state, you can use setState and you would not need a state manager for this. However, there are situations where you want only the widget where a certain variable has been changed to be rebuilt, and this is what GetX does with a mastery never seen before.  
900 -  
901 -That way, if you want an individual controller, you can assign IDs for that, or use GetX. This is up to you, remembering that the more "individual" widgets you have, the more the performance of GetX will stand out, while the performance of GetBuilder should be superior, when there is multiple change of state.  
902 -  
903 -You can use both in any situation, but if you want to tune their application to the maximum possible performance, I would say that: if your variables are changed at different times, use GetX, because there is no competition for it when the subject is to rebuild only what is necessary, if you do not need unique IDs, because all your variables will be changed when you perform an action, use GetBuilder, because it is a simple state updater in blocks, made in a few lines of code, to make just what he promises to do: update state in blocks. There is no way to compare RAM, CPU, or anything else from a giant state manager to a simple StatefulWidget (like GetBuilder) that is updated when you call update(). It was done in a simple way, to have the least computational logic involved, just to fulfill a single purpose and spend the minimum resources possible for that purpose.  
904 -If you want a powerful state manager, you can go without fear to GetX. It does not work with variables, but flows, everything in it is streams under the hood. You can use rxDart in conjunction with it, because everything is stream, you can hear the event of each "variable", because everything in it is stream, it is literally BLoC, easier than MobX, and without code generator or decorations .  
905 -  
906 -If you want power, Get gives you the most advanced state manager you could ever have.  
907 -GetX was built 100% based on Streams, and give you all the firepower that BLoC gave you, with an easier facility than using MobX.  
908 -Without decorations, you can turn anything into Observable with just a ".obs".  
909 -  
910 -Maximum performance: In addition to having a smart algorithm for minimal reconstruction, Get uses comparators to make sure the state has changed. If you experience any errors in your application, and send a duplicate change of state, Get will ensure that your application does not collapse.  
911 -The state only changes if the values ​​change. That's the main difference between Get, and using Computed from MobX. When joining two observables, when one is changed, the hearing of that observable will change. With Get, if you join two variables (which is unnecessary computed for that), GetX (similar to Observer) will only change if it implies a real change of state.  
912 -  
913 -### Usage  
914 -  
915 -You have 3 ways to turn a variable into an observable.  
916 -The first is using Rx{Type}.  
917 -  
918 -```dart  
919 -var count = RxString();  
920 -```  
921 -The second is to use Rx and type it with `Rx<Type>`  
922 -```dart  
923 -var count = Rx<String>();  
924 -```  
925 -  
926 -The third, more practical, easy, and incredible approach, is just to add an .obs to your variable.  
927 -  
928 -```dart  
929 -var count = 0.obs;  
930 -  
931 -// or Rxint count = 0.obs;  
932 -// or Rx<int> count = 0.obs;  
933 -```  
934 -  
935 - As we know, Dart is now heading towards null safety. With that it is a good idea, from now on, you start to use your variables always with an initial value. Transforming a variable into an observable with an initial value with Get is the simplest and most practical approach that currently exists in Flutter. You will literally add a ".obs" to the end of your variable, and that’s it, you’ve made it observable, and its value will be the initial value, this is fantastic!  
936 -  
937 -You can add variables, and if you want to type your widget to get your controller inside, you just need to use GetX widget instead of Obx  
938 -```dart  
939 -final count1 = 0.obs;  
940 -final count2 = 0.obs;  
941 -int get sum => count1.value + count2.value;  
942 -```  
943 -  
944 -```dart  
945 -GetX<Controller>(  
946 - builder: (value) {  
947 - print("count 1 rebuild");  
948 - return Text('${value.count1.value}');  
949 - },  
950 -),  
951 -GetX<Controller>(  
952 - builder: (_) {  
953 - print("count 2 rebuild");  
954 - return Text('${_.count2.value}');  
955 - },  
956 -),  
957 -GetX<Controller>(  
958 - builder: (_) {  
959 - print("count 3 rebuild");  
960 - return Text('${_.sum}');  
961 - },  
962 -),  
963 -```  
964 -  
965 -If we increment the number of count 1, only count 1 and count 3 are reconstructed, because count 1 now has a value of 1, and 1 + 0 = 1, changing the sum value.  
966 -  
967 -If we change count 2, only count2 and 3 are reconstructed, because the value of 2 has changed, and the result of the sum is now 2.  
968 -  
969 -If we add the number 1 to count 1, which already contains 1, no widget is reconstructed. If we add a value of 1 for count 1 and a value of 2 for count 2, only 2 and 3 will be reconstructed, simply because GetX not only changes what is necessary, it avoids duplicating events.  
970 -  
971 -- NOTE: By default, the first event will allow rebuild even if it is the same. We created this behavior due to dualistic variables, such as Boolean.  
972 -Imagine you did this:  
973 -  
974 -```dart  
975 -var isLogged = false.obs;  
976 -```  
977 -  
978 -and then you check if a user is logged in to trigger an event in "ever".  
979 -  
980 -```dart  
981 -onInit(){  
982 - ever(isLogged, fireRoute);  
983 - isLogged.value = await Preferences.hasToken();  
984 -}  
985 -  
986 -fireRoute(logged) {  
987 - if (logged) {  
988 - Get.off(Home());  
989 - } else {  
990 - Get.off(Login());  
991 - }  
992 -}  
993 -```  
994 -  
995 -if hasToken was false, there would be no change to isLogged, so ever would never be called. To avoid this type of behavior, the first change to an observable will always trigger an event, even if it is the same.  
996 -You can remove this behavior if you want, using:  
997 -`isLogged.firstRebuild = false;`  
998 -  
999 -In addition, Get provides refined state control. You can condition an event (such as adding an object to a list), on a certain condition.  
1000 -  
1001 -```dart  
1002 -list.addIf(item<limit, item);  
1003 -```  
1004 -  
1005 -Without decorations, without a code generator, without complications, GetX will change the way you manage your states in Flutter, and that is not a promise, it is a certainty!  
1006 -  
1007 -Do you know Flutter's counter app? Your Controller class might look like this:  
1008 -  
1009 -```dart  
1010 -class CountCtl extends GetxController {  
1011 - final count = 0.obs;  
1012 -}  
1013 -```  
1014 -With a simple:  
1015 -```dart  
1016 -ctl.count.value++  
1017 -```  
1018 -  
1019 -You could update the counter variable in your UI, regardless of where it is stored.  
1020 -  
1021 -### Where .obs can be used  
1022 -You can transform anything on obs:  
1023 -  
1024 -```dart  
1025 -class RxUser {  
1026 - final name = "Camila".obs;  
1027 - final age = 18.obs;  
1028 -}  
1029 -  
1030 -class User {  
1031 - User({String name, int age});  
1032 - final rx = RxUser();  
1033 -  
1034 - String get name => rx.name.value;  
1035 - set name(String value) => rx.name.value = value;  
1036 -  
1037 - int get age => rx.age.value;  
1038 - set age(int value) => rx.age.value = value;  
1039 -}  
1040 -```  
1041 -  
1042 -```dart  
1043 -  
1044 -void main() {  
1045 - final user = User();  
1046 - print(user.name);  
1047 - user.age = 23;  
1048 - user.rx.age.listen((int age) => print(age));  
1049 - user.age = 24;  
1050 - user.age = 25;  
1051 -}  
1052 -___________  
1053 -out:  
1054 -Camila  
1055 -23  
1056 -24  
1057 -25  
1058 -  
1059 -```  
1060 -  
1061 -  
1062 -### Note about Lists  
1063 -Working with Lists using Get is the best and most enjoyable thing in the world. They are completely observable as are the objects within it. That way, if you add a value to a list, it will automatically rebuild the widgets that use it.  
1064 -You also don't need to use ".value" with lists, the amazing dart api allowed us to remove that, unfortunate primitive types like String and int cannot be extended, making the use of .value mandatory, but that won't be a problem if you work with gets and setters for these.  
1065 -  
1066 -```dart  
1067 -final list = List<User>().obs;  
1068 -```  
1069 -  
1070 -```dart  
1071 -ListView.builder (  
1072 - itemCount: list.lenght  
1073 -)  
1074 -```  
1075 -  
1076 -You don't have to work with sets if you don't want to. you can use the "assign 'and" assignAll "api.  
1077 -The "assign" api will clear your list, and add a single object that you want to start there.  
1078 -The "assignAll" api will clear the existing list and add any iterable objects that you inject into it.  
1079 -  
1080 -### Why i have to use .value?  
1081 -We could remove the obligation to use 'value' to String and int with a simple decoration and code generator, but the purpose of this lib is precisely not to need any external dependency. It is to offer an environment ready for programming, involving the essentials (management of routes, dependencies and states), in a simple, light and performance way without needing any external package. You can literally add 3 letters to your pubspec (get) and start programming. All solutions included by default, from route management to state management, aim at ease, productivity and performance. The total weight of this library is less than that of a single state manager, even though it is a complete solution, and that is what you must understand. If you are bothered by value, and like a code generator, MobX is a great alternative, and you can use it in conjunction with Get. For those who want to add a single dependency in pubspec and start programming without worrying about the version of a package being incompatible with another, or if the error of a state update is coming from the state manager or dependency, or still, do not want to worrying about the availability of controllers, whether literally "just programming", get is just perfect.  
1082 -  
1083 -If you have no problem with the MobX code generator, or have no problem with the BLoC boilerplate, you can simply use Get for routes, and forget that it has state manager. Get SEM and RSM were born out of necessity, my company had a project with more than 90 controllers, and the code generator simply took more than 30 minutes to complete its tasks after a Flutter Clean on a reasonably good machine, if your project it has 5, 10, 15 controllers, any state manager will supply you well. If you have an absurdly large project, and code generator is a problem for you, you have been awarded this solution.  
1084 -  
1085 -Obviously, if someone wants to contribute to the project and create a code generator, or something similar, I will link in this readme as an alternative, my need is not the need for all devs, but for now I say, there are good solutions that already do that, like MobX.  
1086 -  
1087 -### Obx()  
1088 -  
1089 -Typing in Get using Bindings is unnecessary. you can use the Obx widget instead of GetX which only receives the anonymous function that creates a widget.  
1090 -Obviously, if you don't use a type, you will need to have an instance of your controller to use the variables, or use `Get.find<Controller>()` .value or Controller.to.value to retrieve the value.  
1091 -  
1092 -### Workers:  
1093 -Workers will assist you, triggering specific callbacks when an event occurs.  
1094 -  
1095 -  
1096 -```dart  
1097 -/// Called every time the variable $_ is changed  
1098 -ever(count1, (_) => print("$_ has been changed"));  
1099 -  
1100 -/// Called only first time the variable $_ is changed  
1101 -once(count1, (_) => print("$_ was changed once"));  
1102 -  
1103 -/// Anti DDos - Called every time the user stops typing for 1 second, for example.  
1104 -debounce(count1, (_) => print("debouce$_"), time: Duration(seconds: 1));  
1105 -  
1106 -/// Ignore all changes within 1 second.  
1107 -interval(count1, (_) => print("interval $_"), time: Duration(seconds: 1));  
1108 -```  
1109 -- ever  
1110 -'ever' is called every time its variable is changed. That's it.  
1111 -  
1112 -- ever  
1113 -'once' is called only the first time the variable has been changed.  
1114 -  
1115 -- debounce  
1116 -'debounce' is very useful in search functions, where you only want the API to be called when the user finishes typing. If the user types "Jonny", you will have 5 searches in the APIs, by the letter J, o, n, n, and y. With Get this does not happen, because you will have a "debounce" Worker that will only be triggered at the end of typing.  
1117 -  
1118 -- interval  
1119 -'interval' is different from the debouce. debouce if the user makes 1000 changes to a variable within 1 second, he will send only the last one after the stipulated timer (the default is 800 milliseconds). Interval will instead ignore all user actions for the stipulated period. If you send events for 1 minute, 1000 per second, debounce will only send you the last one, when the user stops strafing events. interval will deliver events every second, and if set to 3 seconds, it will deliver 20 events that minute. This is recommended to avoid abuse, in functions where the user can quickly click on something and get some advantage (imagine that the user can earn coins by clicking on something, if he clicked 300 times in the same minute, he would have 300 coins, using interval, you you can set a time frame for 3 seconds, and even then clicking 300 or a thousand times, the maximum he would get in 1 minute would be 20 coins, clicking 300 or 1 million times). The debounce is suitable for anti-DDos, for functions like search where each change to onChange would cause a query to your api. Debounce will wait for the user to stop typing the name, to make the request. If it were used in the coin scenario mentioned above, the user would only win 1 coin, because it is only executed, when the user "pauses" for the established time.  
1120 -  
1121 -  
1122 -## Mixing the two state managers  
1123 -Some people opened a feature request, as they wanted to use only one type of reactive variable, and the other mechanics, and needed to insert an Obx into a GetBuilder for this. Thinking about it MixinBuilder was created. It allows both reactive changes by changing ".obs" variables, and mechanical updates via update(). However, of the 4 widgets he is the one that consumes the most resources, since in addition to having a Subscription to receive change events from his children, he subscribes to the update method of his controller.  
1124 -  
1125 -Extending GetxController is important, as they have life cycles, and can "start" and "end" events in their onInit() and onClose() methods. You can use any class for this, but I strongly recommend you use the GetxController class to place your variables, whether they are observable or not.  
1126 -  
1127 -## GetBuilder vs GetX vs Obx vs MixinBuilder  
1128 -In a decade working with programming I was able to learn some valuable lessons.  
1129 -  
1130 -My first contact with reactive programming was so "wow, this is incredible" and in fact reactive programming is incredible.  
1131 -However, it is not suitable for all situations. Often all you need is to change the state of 2 or 3 widgets at the same time, or an ephemeral change of state, in which case reactive programming is not bad, but it is not appropriate.  
1132 -  
1133 -Reactive programming has a higher consumption of RAM consumption that can be compensated for by the individual workflow, which will ensure that only one widget is rebuilt and when necessary, but creating a list with 80 objects, each with several streams is not a good one idea. Open the dart inspect and check how much a StreamBuilder consumes, and you'll understand what I'm trying to tell you.  
1134 -  
1135 -With that in mind, I created the simple state manager. It is simple, and that is exactly what you should demand from it: updating state in blocks in a simple way, and in the most economical way.  
1136 -  
1137 -GetBuilder is very economical in RAM, and there is hardly a more economical approach than him (at least I can't imagine one, if it exists, please let us know).  
1138 -  
1139 -However, GetBuilder is still a mechanical state manager, you need to call update() just like you would need to call Provider's notifyListeners().  
1140 -  
1141 -There are other situations where reactive programming is really interesting, and not working with it is the same as reinventing the wheel. With that in mind, GetX was created to provide everything that is most modern and advanced in a state manager. It updates only what is necessary and when necessary, if you have an error and send 300 state changes simultaneously, GetX will filter and update the screen only if the state actually changes.  
1142 -  
1143 -GetX is still more economical than any other reactive state manager, but it consumes a little more RAM than GetBuilder. Thinking about it and aiming to maximize the consumption of resources that Obx was created. Unlike GetX and GetBuilder, you will not be able to initialize a controller inside an Obx, it is just a Widget with a StreamSubscription that receives change events from your children, that's all. It is more economical than GetX, but loses to GetBuilder, which was to be expected, since it is reactive, and GetBuilder has the most simplistic approach that exists, of storing a widget's hashcode and its StateSetter. With Obx you don't need to write your controller type, and you can hear the change from multiple different controllers, but it needs to be initialized before, either using the example approach at the beginning of this readme, or using the Bindings class.  
1144 -  
1145 -  
1146 -# Dependency Management  
1147 -  
1148 -  
1149 -## Simple Instance Manager  
1150 -- Note: If you are using Get's State Manager, you don't have to worry about that, just read for information, but pay more attention to the bindings api, which will do all of this automatically for you.  
1151 -  
1152 -Are you already using Get and want to make your project as lean as possible? 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:  
1153 -  
1154 -```dart  
1155 -Controller controller = Get.put(Controller()); // Rather Controller controller = Controller();  
1156 -```  
1157 -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.  
1158 -So you can use your controller (or class Bloc) normally  
1159 -  
1160 -```dart  
1161 -controller.fetchApi();  
1162 -```  
1163 -  
1164 -Imagine that you have navigated through numerous routes, and you need a 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:  
1165 -  
1166 -```dart  
1167 -Controller controller = Get.find();  
1168 -//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.  
1169 -```  
1170 -And then you will be able to recover your controller data that was obtained back there:  
1171 -  
1172 -```dart  
1173 -Text(controller.textFromApi);  
1174 -```  
1175 -  
1176 -Looking for lazy loading? You can declare all your controllers, and it will be called only when someone needs it. You can do this with:  
1177 -```dart  
1178 -Get.lazyPut<Service>(()=> ApiMock());  
1179 -/// ApiMock will only be called when someone uses Get.find<Service> for the first time  
1180 -```  
1181 -  
1182 -If you want to register an asynchronous instance, you can use Get.putAsync.  
1183 -```dart  
1184 -Get.putAsync<SharedPreferences>(() async {  
1185 - final prefs = await SharedPreferences.getInstance();  
1186 - await prefs.setInt('counter', 12345);  
1187 - return prefs;  
1188 -});  
1189 -```  
1190 -usage:  
1191 -  
1192 -```dart  
1193 - int count = Get.find<SharedPreferences>().getInt('counter');  
1194 - print(count);  
1195 - // out: 12345  
1196 -}  
1197 -```  
1198 -  
1199 -To remove a instance of Get:  
1200 -```dart  
1201 -Get.delete<Controller>();  
1202 -```  
1203 -  
1204 -  
1205 -## Bindings  
1206 -One of the great differentials of this package, perhaps, is the possibility of full integration of the routes, state manager and dependency manager.  
1207 -When a route is removed from the Stack, all controllers, variables, and instances of objects related to it are removed from memory. If you are using streams or timers, they will be closed automatically, and you don't have to worry about any of that.  
1208 -In version 2.10 Get completely implemented the Bindings API.  
1209 -Now you no longer need to use the init method. You don't even have to type your controllers if you don't want to. You can start your controllers and services in the appropriate place for that.  
1210 -The Binding class is a class that will decouple dependency injection, while "binding" routes to the state manager and dependency manager.  
1211 -This allows Get to know which screen is being displayed when a particular controller is used and to know where and how to dispose of it.  
1212 -In addition, the Binding class will allow you to have SmartManager configuration control. You can configure the dependencies to be arranged when removing a route from the stack, or when the widget that used it is laid out, or neither. You will have intelligent dependency management working for you, but even so, you can configure it as you wish.  
1213 -  
1214 -### How to use  
1215 -- Create a class and implements Binding  
1216 -  
1217 -```dart  
1218 -class HomeBinding implements Bindings{  
1219 -```  
1220 -  
1221 -Your IDE will automatically ask you to override the "dependencies" method, and you just need to click on the lamp, override the method, and insert all the classes you are going to use on that route:  
1222 -  
1223 -```dart  
1224 -class HomeBinding implements Bindings{  
1225 - @override  
1226 - void dependencies() {  
1227 - Get.lazyPut<ControllerX>(() => ControllerX());  
1228 - Get.lazyPut<Service>(()=> Api());  
1229 - }  
1230 -} 138 +var data = await Get.to(Payment());
1231 ``` 139 ```
1232 -Now you just need to inform your route, that you will use that binding to make the connection between route manager, dependencies and states.  
1233 140
1234 -- Using named routes:  
1235 -```dart  
1236 -namedRoutes: {  
1237 - '/': GetRoute(Home(), binding: HomeBinding())  
1238 -}  
1239 -``` 141 +Noticed that you didn't had 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.
1240 142
1241 -- Using normal routes:  
1242 -```dart  
1243 -Get.to(Home(), binding: HomeBinding());  
1244 -``` 143 +**Note: Get work with named routes too! As said in the beggining, there is a in-depth documentation [here](./docs/route_management.md)**
1245 144
1246 -There, you don't have to worry about memory management of your application anymore, Get will do it for you. 145 +## Dependency management
1247 146
1248 -The Binding class is called when a route is called, you can create an "initialBinding in your GetMaterialApp to insert all the dependencies that will be created.  
1249 -```dart  
1250 -GetMaterialApp(  
1251 - initialBinding: SampleBind(),  
1252 - home: Home(),  
1253 -);  
1254 -```  
1255 -## SmartManagement  
1256 -Always prefer to use standard SmartManagement (full), you do not need to configure anything for that, Get already gives it to you by default. It will surely eliminate all your disused controllers from memory, as its refined control removes the dependency, even if a failure occurs and a widget that uses it is not properly disposed.  
1257 -The "full" mode is also safe enough to be used with StatelessWidget, as it has numerous security callbacks that will prevent a controller from remaining in memory if it is not being used by any widget, and disposition is not important here. However, if you are bothered by the default behavior, or just don't want it to happen, Get offers other, more lenient options for intelligent memory management, such as SmartManagement.onlyBuilders, which will depend on the effective removal of widgets using the controller. tree to remove it, and you can prevent a controller from being deployed using "autoRemove: false" in your GetBuilder/GetX.  
1258 -With this option, only controllers started in "init:" or loaded into a Binding with "Get.lazyPut" will be disposed, if you use Get.put or any other approach, SmartManagement will not have permissions to exclude this dependency.  
1259 -With the default behavior, even widgets instantiated with "Get.put" will be removed, unlike SmartManagement.onlyBuilders.  
1260 -SmartManagement.keepFactory is like SmartManagement.full, with one difference. SmartManagement.full purges the factories from the premises, so that Get.lazyPut() will only be able to be called once and your factory and references will be self-destructing. SmartManagement.keepFactory will remove its dependencies when necessary, however, it will keep the "shape" of these, to make an equal one if you need an instance of that again.  
1261 -Instead of using SmartManagement.keepFactory you can use Bindings.  
1262 -Bindings creates transitory factories, which are created the moment you click to go to another screen, and will be destroyed as soon as the screen-changing animation happens. It is so little time that the analyzer will not even be able to register it. When you navigate to this screen again, a new temporary factory will be called, so this is preferable to using SmartManagement.keepFactory, but if you don't want to create Bindings, or want to keep all your dependencies on the same Binding, it will certainly help you . Factories take up little memory, they don't hold instances, but a function with the "shape" of that class you want. This is very little, but since the purpose of this lib is to get the maximum performance possible using the minimum resources, Get removes even the factories by default. Use whichever is most convenient for you. 147 +# How to contribute
1263 148
1264 -- NOTE: DO NOT USE SmartManagement.keepFactory if you are using multiple Bindings. It was designed to be used without Bindings, or with a single Binding linked in the GetMaterialApp's initialBinding. 149 +*Want to contribute to the project? We will be proud to highlight you as one of our collaborators. Here are some points where you can contribute and make Get (and Flutter) even better.*
1265 150
1266 -- NOTE2: Using Bindings is completely optional, you can use Get.put() and Get.find() on classes that use a given controller without any problem.  
1267 -However, if you work with Services or any other abstraction, I recommend using Bindings for a larger organization. 151 +- Helping to translate the readme into other languages.
  152 +- Adding documentation to the readme (not even half of Get's functions have been documented yet).
  153 +- Write articles or make videos teaching how to use Get (they will be inserted in the Readme and in the future in our Wiki).
  154 +- Offering PRs for code/tests.
  155 +- Including new functions.
1268 156
  157 +Any contribution is welcome!
1269 158
1270 # Utils 159 # Utils
1271 160
1272 ## Change Theme 161 ## Change Theme
  162 +
1273 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 Get. 163 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 Get.
1274 164
1275 You can create your custom theme and simply add it within Get.changeTheme without any boilerplate for that: 165 You can create your custom theme and simply add it within Get.changeTheme without any boilerplate for that:
1276 166
1277 -  
1278 ```dart 167 ```dart
1279 Get.changeTheme(ThemeData.light()); 168 Get.changeTheme(ThemeData.light());
1280 ``` 169 ```
@@ -1287,14 +176,12 @@ Get.changeTheme(Get.isDarkMode? ThemeData.light(): ThemeData.dark()); @@ -1287,14 +176,12 @@ Get.changeTheme(Get.isDarkMode? ThemeData.light(): ThemeData.dark());
1287 176
1288 When darkmode is activated, it will switch to the light theme, and when the light theme is activated, it will change to dark. 177 When darkmode is activated, it will switch to the light theme, and when the light theme is activated, it will change to dark.
1289 178
1290 -  
1291 If you want to know in depth how to change the theme, you can follow this tutorial on Medium that even teaches the persistence of the theme using Get: 179 If you want to know in depth how to change the theme, you can follow this tutorial on Medium that even teaches the persistence of the theme using Get:
1292 180
1293 - [Dynamic Themes in 3 lines using Get](https://medium.com/swlh/flutter-dynamic-themes-in-3-lines-c3b375f292e3) - Tutorial by [Rod Brown](https://github.com/RodBr). 181 - [Dynamic Themes in 3 lines using Get](https://medium.com/swlh/flutter-dynamic-themes-in-3-lines-c3b375f292e3) - Tutorial by [Rod Brown](https://github.com/RodBr).
1294 182
1295 -  
1296 -  
1297 ## Other Advanced APIs and Manual configurations 183 ## Other Advanced APIs and Manual configurations
  184 +
1298 GetMaterialApp configures everything for you, but if you want to configure Get Manually using advanced APIs. 185 GetMaterialApp configures everything for you, but if you want to configure Get Manually using advanced APIs.
1299 186
1300 ```dart 187 ```dart
@@ -1348,8 +235,8 @@ Get.contextOverlay // Gives the context of the snackbar/dialog/bottomsheet in th @@ -1348,8 +235,8 @@ Get.contextOverlay // Gives the context of the snackbar/dialog/bottomsheet in th
1348 235
1349 ``` 236 ```
1350 237
1351 -  
1352 ### Optional Global Settings 238 ### Optional Global Settings
  239 +
1353 You can create Global settings for Get. Just add Get.config to your code before pushing any route or do it directly in your GetMaterialApp 240 You can create Global settings for Get. Just add Get.config to your code before pushing any route or do it directly in your GetMaterialApp
1354 241
1355 ```dart 242 ```dart
@@ -1370,14 +257,15 @@ Get.config( @@ -1370,14 +257,15 @@ Get.config(
1370 ``` 257 ```
1371 258
1372 # Breaking changes from 2.0 259 # Breaking changes from 2.0
  260 +
1373 1- Rx types: 261 1- Rx types:
1374 -Before: StringX now: RxString 262 +Before: StringX now: RxString
1375 263
1376 -Before: IntX now: RxInt 264 +Before: IntX now: RxInt
1377 265
1378 -Before: MapX now: RxMax 266 +Before: MapX now: RxMax
1379 267
1380 -Before: ListX now: RxList 268 +Before: ListX now: RxList
1381 269
1382 Before: NumX now: RxNum 270 Before: NumX now: RxNum
1383 271
@@ -1385,9 +273,9 @@ Before: RxDouble now: RxDouble @@ -1385,9 +273,9 @@ Before: RxDouble now: RxDouble
1385 273
1386 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. 274 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.
1387 275
1388 -  
1389 -2- NamedRoutes 276 +2- NamedRoutes
1390 Before: 277 Before:
  278 +
1391 ```dart 279 ```dart
1392 GetMaterialApp( 280 GetMaterialApp(
1393 namedRoutes: { 281 namedRoutes: {
@@ -1395,7 +283,9 @@ GetMaterialApp( @@ -1395,7 +283,9 @@ GetMaterialApp(
1395 } 283 }
1396 ) 284 )
1397 ``` 285 ```
  286 +
1398 Now: 287 Now:
  288 +
1399 ```dart 289 ```dart
1400 GetMaterialApp( 290 GetMaterialApp(
1401 getPages: [ 291 getPages: [
@@ -1421,5 +311,20 @@ GetMaterialApp( @@ -1421,5 +311,20 @@ GetMaterialApp(
1421 ) 311 )
1422 ``` 312 ```
1423 313
1424 -  
1425 This library will always be updated and implementing new features. Feel free to offer PRs and contribute to them. 314 This library will always be updated and implementing new features. Feel free to offer PRs and contribute to them.
  315 +
  316 +# Why I made this package
  317 +
  318 +The problem that this package tries to solve is to have most of what you need in only one package. One day, when i update some of my apps to work with Flutter 1.9, something bad happened: Everything broke.
  319 +
  320 +All of my libraries broke down, the libraries started to be prevented from using hyphen "-". Some updated the package, others did not. The others I had to look for because the project did not compile. Other libs just became incompatible with the current version, such as the image_extended that I offered a PR there to be able to solve, and all because of a simple update.
  321 +
  322 +I lost 2 days of work just looking for errors to know where they came from and what lib they came from.
  323 +
  324 +I confess that it was one of the most stressful situations I have ever gone through in my life. It was exactly on that day that I decided to do everything in one package.
  325 +
  326 +I know this looks a lot like the package being based on my personal experiences, but I am a programmer, and I try to solve problems always from the programmer's perspective. I don't care about anything other than making my life and other devs easier with this library.
  327 +
  328 +Every time I go through a frustrating experience, I write it down in my schedule, and try to resolve it after completing the project.
  329 +
  330 +And then I decided to make a package that have the three things that you will always use: State management, route management and Dependency injection/management
  1 +
  2 +# Dependency Management
  3 +
  4 +## Simple Instance Manager
  5 +
  6 +- Note: If you are using Get's State Manager, you don't have to worry about that, just read for information, but pay more attention to the bindings api, which will do all of this automatically for you.
  7 +
  8 +Are you already using Get and want to make your project as lean as possible? 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:
  9 +
  10 +```dart
  11 +Controller controller = Get.put(Controller()); // Rather Controller controller = Controller();
  12 +```
  13 +
  14 +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.
  15 +So you can use your controller (or class Bloc) normally
  16 +
  17 +```dart
  18 +controller.fetchApi();
  19 +```
  20 +
  21 +Imagine that you have navigated through numerous routes, and you need a 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:
  22 +
  23 +```dart
  24 +Controller controller = Get.find();
  25 +//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.
  26 +```
  27 +
  28 +And then you will be able to recover your controller data that was obtained back there:
  29 +
  30 +```dart
  31 +Text(controller.textFromApi);
  32 +```
  33 +
  34 +Looking for lazy loading? You can declare all your controllers, and it will be called only when someone needs it. You can do this with:
  35 +
  36 +```dart
  37 +Get.lazyPut<Service>(()=> ApiMock());
  38 +/// ApiMock will only be called when someone uses Get.find<Service> for the first time
  39 +```
  40 +
  41 +If you want to register an asynchronous instance, you can use Get.putAsync.
  42 +
  43 +```dart
  44 +Get.putAsync<SharedPreferences>(() async {
  45 + final prefs = await SharedPreferences.getInstance();
  46 + await prefs.setInt('counter', 12345);
  47 + return prefs;
  48 +});
  49 +```
  50 +
  51 +usage:
  52 +
  53 +```dart
  54 +int count = Get.find<SharedPreferences>().getInt('counter');
  55 +print(count); // out: 12345
  56 +```
  57 +
  58 +To remove a instance of Get:
  59 +
  60 +```dart
  61 +Get.delete<Controller>();
  62 +```
  63 +
  64 +## Bindings
  65 +
  66 +One of the great differentials of this package, perhaps, is the possibility of full integration of the routes, state manager and dependency manager.
  67 +When a route is removed from the Stack, all controllers, variables, and instances of objects related to it are removed from memory. If you are using streams or timers, they will be closed automatically, and you don't have to worry about any of that.
  68 +In version 2.10 Get completely implemented the Bindings API.
  69 +Now you no longer need to use the init method. You don't even have to type your controllers if you don't want to. You can start your controllers and services in the appropriate place for that.
  70 +The Binding class is a class that will decouple dependency injection, while "binding" routes to the state manager and dependency manager.
  71 +This allows Get to know which screen is being displayed when a particular controller is used and to know where and how to dispose of it.
  72 +In addition, the Binding class will allow you to have SmartManager configuration control. You can configure the dependencies to be arranged when removing a route from the stack, or when the widget that used it is laid out, or neither. You will have intelligent dependency management working for you, but even so, you can configure it as you wish.
  73 +
  74 +### How to use
  75 +
  76 +- Create a class and implements Binding
  77 +
  78 +```dart
  79 +class HomeBinding implements Bindings{
  80 +```
  81 +
  82 +Your IDE will automatically ask you to override the "dependencies" method, and you just need to click on the lamp, override the method, and insert all the classes you are going to use on that route:
  83 +
  84 +```dart
  85 +class HomeBinding implements Bindings{
  86 + @override
  87 + void dependencies() {
  88 + Get.lazyPut<ControllerX>(() => ControllerX());
  89 + Get.lazyPut<Service>(()=> Api());
  90 + }
  91 +}
  92 +```
  93 +
  94 +Now you just need to inform your route, that you will use that binding to make the connection between route manager, dependencies and states.
  95 +
  96 +- Using named routes:
  97 +
  98 +```dart
  99 +namedRoutes: {
  100 + '/': GetRoute(Home(), binding: HomeBinding())
  101 +}
  102 +```
  103 +
  104 +- Using normal routes:
  105 +
  106 +```dart
  107 +Get.to(Home(), binding: HomeBinding());
  108 +```
  109 +
  110 +There, you don't have to worry about memory management of your application anymore, Get will do it for you.
  111 +
  112 +The Binding class is called when a route is called, you can create an "initialBinding in your GetMaterialApp to insert all the dependencies that will be created.
  113 +
  114 +```dart
  115 +GetMaterialApp(
  116 + initialBinding: SampleBind(),
  117 + home: Home(),
  118 +);
  119 +```
  120 +
  121 +## SmartManagement
  122 +
  123 +Always prefer to use standard SmartManagement (full), you do not need to configure anything for that, Get already gives it to you by default. It will surely eliminate all your disused controllers from memory, as its refined control removes the dependency, even if a failure occurs and a widget that uses it is not properly disposed.
  124 +The "full" mode is also safe enough to be used with StatelessWidget, as it has numerous security callbacks that will prevent a controller from remaining in memory if it is not being used by any widget, and disposition is not important here. However, if you are bothered by the default behavior, or just don't want it to happen, Get offers other, more lenient options for intelligent memory management, such as SmartManagement.onlyBuilders, which will depend on the effective removal of widgets using the controller. tree to remove it, and you can prevent a controller from being deployed using "autoRemove: false" in your GetBuilder/GetX.
  125 +With this option, only controllers started in "init:" or loaded into a Binding with "Get.lazyPut" will be disposed, if you use Get.put or any other approach, SmartManagement will not have permissions to exclude this dependency.
  126 +With the default behavior, even widgets instantiated with "Get.put" will be removed, unlike SmartManagement.onlyBuilders.
  127 +SmartManagement.keepFactory is like SmartManagement.full, with one difference. SmartManagement.full purges the factories from the premises, so that Get.lazyPut() will only be able to be called once and your factory and references will be self-destructing. SmartManagement.keepFactory will remove its dependencies when necessary, however, it will keep the "shape" of these, to make an equal one if you need an instance of that again.
  128 +Instead of using SmartManagement.keepFactory you can use Bindings.
  129 +Bindings creates transitory factories, which are created the moment you click to go to another screen, and will be destroyed as soon as the screen-changing animation happens. It is so little time that the analyzer will not even be able to register it. When you navigate to this screen again, a new temporary factory will be called, so this is preferable to using SmartManagement.keepFactory, but if you don't want to create Bindings, or want to keep all your dependencies on the same Binding, it will certainly help you . Factories take up little memory, they don't hold instances, but a function with the "shape" of that class you want. This is very little, but since the purpose of this lib is to get the maximum performance possible using the minimum resources, Get removes even the factories by default. Use whichever is most convenient for you.
  130 +
  131 +- NOTE: DO NOT USE SmartManagement.keepFactory if you are using multiple Bindings. It was designed to be used without Bindings, or with a single Binding linked in the GetMaterialApp's initialBinding.
  132 +
  133 +- NOTE2: Using Bindings is completely optional, you can use Get.put() and Get.find() on classes that use a given controller without any problem.
  134 +However, if you work with Services or any other abstraction, I recommend using Bindings for a larger organization.
  1 +
  2 +# Route Management
  3 +
  4 +## How to use
  5 +
  6 +Add this to your pubspec.yaml file:
  7 +
  8 +```yaml
  9 +dependencies:
  10 + get:
  11 +```
  12 +
  13 +If you are going to use routes/snackbars/dialogs/bottomsheets without context, or use the high-level Get APIs, you need to simply add "Get" before your MaterialApp, turning it into GetMaterialApp and enjoy!
  14 +
  15 +```dart
  16 +GetMaterialApp( // Before: MaterialApp(
  17 + home: MyHome(),
  18 +)
  19 +```
  20 +
  21 +## Navigation without named routes
  22 +
  23 +To navigate to a new screen:
  24 +
  25 +```dart
  26 +Get.to(NextScreen());
  27 +```
  28 +
  29 +To close snackbars, dialogs, bottomsheets, or anything you would normally close with Navigator.pop(context);
  30 +
  31 +```dart
  32 +Get.back();
  33 +```
  34 +
  35 +To go to the next screen and no option to go back to the previous screen (for use in SplashScreens, login screens and etc.)
  36 +
  37 +```dart
  38 +Get.off(NextScreen());
  39 +```
  40 +
  41 +To go to the next screen and cancel all previous routes (useful in shopping carts, polls, and tests)
  42 +
  43 +```dart
  44 +Get.offAll(NextScreen());
  45 +```
  46 +
  47 +To navigate to the next route, and receive or update data as soon as you return from it:
  48 +
  49 +```dart
  50 +var data = await Get.to(Payment());
  51 +```
  52 +
  53 +on other screen, send a data for previous route:
  54 +
  55 +```dart
  56 +Get.back(result: 'success');
  57 +```
  58 +
  59 +And use it:
  60 +
  61 +ex:
  62 +
  63 +```dart
  64 +if(data == 'success') madeAnything();
  65 +```
  66 +
  67 +Don't you want to learn our syntax?
  68 +Just change the Navigator (uppercase) to navigator (lowercase), and you will have all the functions of the standard navigation, without having to use context
  69 +Example:
  70 +
  71 +```dart
  72 +
  73 +// Default Flutter navigator
  74 +Navigator.of(context).push(
  75 + context,
  76 + MaterialPageRoute(
  77 + builder: (BuildContext context) {
  78 + return HomePage();
  79 + },
  80 + ),
  81 +);
  82 +
  83 +// Get using Flutter syntax without needing context
  84 +navigator.push(
  85 + MaterialPageRoute(
  86 + builder: (_) {
  87 + return HomePage();
  88 + },
  89 + ),
  90 +);
  91 +
  92 +// Get syntax (It is much better, but you have the right to disagree)
  93 +Get.to(HomePage());
  94 +
  95 +
  96 +```
  97 +
  98 +## Navigation with named routes
  99 +
  100 +- If you prefer to navigate by namedRoutes, Get also supports this.
  101 +
  102 +To navigate to nextScreen
  103 +
  104 +```dart
  105 +Get.toNamed("/NextScreen");
  106 +```
  107 +
  108 +To navigate and remove the previous screen from the tree.
  109 +
  110 +```dart
  111 +Get.offNamed("/NextScreen");
  112 +```
  113 +
  114 +To navigate and remove all previous screens from the tree.
  115 +
  116 +```dart
  117 +Get.offAllNamed("/NextScreen");
  118 +```
  119 +
  120 +To define routes, use GetMaterialApp:
  121 +
  122 +```dart
  123 +void main() {
  124 + runApp(
  125 + GetMaterialApp(
  126 + initialRoute: '/',
  127 + getPages: [
  128 + GetPage(name: '/', page: () => MyHomePage()),
  129 + GetPage(name: '/second', page: () => Second()),
  130 + GetPage(
  131 + name: '/third',
  132 + page: () => Third(),
  133 + transition: Transition.zoom
  134 + ),
  135 + ],
  136 + )
  137 + );
  138 +}
  139 +```
  140 +
  141 +### Send data to named Routes
  142 +
  143 +Just send what you want for arguments. Get accepts anything here, whether it is a String, a Map, a List, or even a class instance.
  144 +
  145 +```dart
  146 +Get.toNamed("/NextScreen", arguments: 'Get is the best');
  147 +```
  148 +
  149 +on your class or controller:
  150 +
  151 +```dart
  152 +print(Get.arguments);
  153 +//print out: Get is the best
  154 +```
  155 +
  156 +### Dynamic urls links
  157 +
  158 +Get offer advanced dynamic urls just like on the Web. Web developers have probably already wanted this feature on Flutter, and most likely have seen a package promise this feature and deliver a totally different syntax than a URL would have on web, but Get also solves that.
  159 +
  160 +```dart
  161 +Get.offAllNamed("/NextScreen?device=phone&id=354&name=Enzo");
  162 +```
  163 +
  164 +on your controller/bloc/stateful/stateless class:
  165 +
  166 +```dart
  167 +print(Get.parameters['id']);
  168 +// out: 354
  169 +print(Get.parameters['name']);
  170 +// out: Enzo
  171 +```
  172 +
  173 +You can also receive NamedParameters with Get easily:
  174 +
  175 +```dart
  176 +void main() {
  177 + runApp(
  178 + GetMaterialApp(
  179 + initialRoute: '/',
  180 + getPages: [
  181 + GetPage(
  182 + name: '/',
  183 + page: () => MyHomePage(),
  184 + ),
  185 + GetPage(
  186 + name: '/profile/',
  187 + page: () => MyProfile(),
  188 + ),
  189 + //You can define a different page for routes with arguments, and another without arguments, but for that you must use the slash '/' on the route that will not receive arguments as above.
  190 + GetPage(
  191 + name: '/profile/:user',
  192 + page: () => UserProfile(),
  193 + ),
  194 + GetPage(
  195 + name: '/third',
  196 + page: () => Third(),
  197 + transition: Transition.cupertino
  198 + ),
  199 + ],
  200 + )
  201 + );
  202 +}
  203 +```
  204 +
  205 +Send data on route name
  206 +
  207 +```dart
  208 +Get.toNamed("/second/34954");
  209 +```
  210 +
  211 +On second screen take the data by parameter
  212 +
  213 +```dart
  214 +print(Get.parameters['user']);
  215 +// out: 34954
  216 +```
  217 +
  218 +And now, all you need to do is use Get.toNamed() to navigate your named routes, without any context (you can call your routes directly from your BLoC or Controller class), and when your app is compiled to the web, your routes will appear in the url <3
  219 +
  220 +### Middleware
  221 +
  222 +If you want listen Get events to trigger actions, you can to use routingCallback to it
  223 +
  224 +```dart
  225 +GetMaterialApp(
  226 + routingCallback: (routing) {
  227 + if(routing.current == '/second'){
  228 + openAds();
  229 + }
  230 + }
  231 +)
  232 +```
  233 +
  234 +If you are not using GetMaterialApp, you can use the manual API to attach Middleware observer.
  235 +
  236 +```dart
  237 +void main() {
  238 + runApp(
  239 + MaterialApp(
  240 + onGenerateRoute: Router.generateRoute,
  241 + initialRoute: "/",
  242 + navigatorKey: Get.key,
  243 + navigatorObservers: [
  244 + GetObserver(MiddleWare.observer), // HERE !!!
  245 + ],
  246 + ),
  247 + );
  248 +}
  249 +```
  250 +
  251 +Create a MiddleWare class
  252 +
  253 +```dart
  254 +class MiddleWare {
  255 + static observer(Routing routing) {
  256 + /// You can listen in addition to the routes, the snackbars, dialogs and bottomsheets on each screen.
  257 + ///If you need to enter any of these 3 events directly here,
  258 + ///you must specify that the event is != Than you are trying to do.
  259 + if (routing.current == '/second' && !routing.isSnackbar) {
  260 + Get.snackbar("Hi", "You are on second route");
  261 + } else if (routing.current =='/third'){
  262 + print('last route called');
  263 + }
  264 + }
  265 +}
  266 +```
  267 +
  268 +Now, use Get on your code:
  269 +
  270 +```dart
  271 +class First extends StatelessWidget {
  272 + @override
  273 + Widget build(BuildContext context) {
  274 + return Scaffold(
  275 + appBar: AppBar(
  276 + leading: IconButton(
  277 + icon: Icon(Icons.add),
  278 + onPressed: () {
  279 + Get.snackbar("hi", "i am a modern snackbar");
  280 + },
  281 + ),
  282 + title: Text('First Route'),
  283 + ),
  284 + body: Center(
  285 + child: RaisedButton(
  286 + child: Text('Open route'),
  287 + onPressed: () {
  288 + Get.toNamed("/second");
  289 + },
  290 + ),
  291 + ),
  292 + );
  293 + }
  294 +}
  295 +
  296 +class Second extends StatelessWidget {
  297 + @override
  298 + Widget build(BuildContext context) {
  299 + return Scaffold(
  300 + appBar: AppBar(
  301 + leading: IconButton(
  302 + icon: Icon(Icons.add),
  303 + onPressed: () {
  304 + Get.snackbar("hi", "i am a modern snackbar");
  305 + },
  306 + ),
  307 + title: Text('second Route'),
  308 + ),
  309 + body: Center(
  310 + child: RaisedButton(
  311 + child: Text('Open route'),
  312 + onPressed: () {
  313 + Get.toNamed("/third");
  314 + },
  315 + ),
  316 + ),
  317 + );
  318 + }
  319 +}
  320 +
  321 +class Third extends StatelessWidget {
  322 + @override
  323 + Widget build(BuildContext context) {
  324 + return Scaffold(
  325 + appBar: AppBar(
  326 + title: Text("Third Route"),
  327 + ),
  328 + body: Center(
  329 + child: RaisedButton(
  330 + onPressed: () {
  331 + Get.back();
  332 + },
  333 + child: Text('Go back!'),
  334 + ),
  335 + ),
  336 + );
  337 + }
  338 +}
  339 +```
  340 +
  341 +## Navigation without context
  342 +
  343 +### SnackBars
  344 +
  345 +To have a simple SnackBar with Flutter, you must get the context of Scaffold, or you must use a GlobalKey attached to your Scaffold
  346 +
  347 +```dart
  348 +final snackBar = SnackBar(
  349 + content: Text('Hi!'),
  350 + action: SnackBarAction(
  351 + label: 'I am a old and ugly snackbar :(',
  352 + onPressed: (){}
  353 + ),
  354 +);
  355 +// Find the Scaffold in the widget tree and use
  356 +// it to show a SnackBar.
  357 +Scaffold.of(context).showSnackBar(snackBar);
  358 +```
  359 +
  360 +With Get:
  361 +
  362 +```dart
  363 +Get.snackbar('Hi', 'i am a modern snackbar');
  364 +```
  365 +
  366 +With Get, all you have to do is call your Get.snackbar from anywhere in your code or customize it however you want!
  367 +
  368 +```dart
  369 +Get.snackbar(
  370 + "Hey i'm a Get SnackBar!", // title
  371 + "It's unbelievable! I'm using SnackBar without context, without boilerplate, without Scaffold, it is something truly amazing!", // message
  372 + icon: Icon(Icons.alarm),
  373 + shouldIconPulse: true,
  374 + onTap:(){},
  375 + barBlur: 20,
  376 + isDismissible: true,
  377 + duration: Duration(seconds: 3),
  378 +);
  379 +
  380 +
  381 + ////////// ALL FEATURES //////////
  382 + // Color colorText,
  383 + // Duration duration,
  384 + // SnackPosition snackPosition,
  385 + // Widget titleText,
  386 + // Widget messageText,
  387 + // bool instantInit,
  388 + // Widget icon,
  389 + // bool shouldIconPulse,
  390 + // double maxWidth,
  391 + // EdgeInsets margin,
  392 + // EdgeInsets padding,
  393 + // double borderRadius,
  394 + // Color borderColor,
  395 + // double borderWidth,
  396 + // Color backgroundColor,
  397 + // Color leftBarIndicatorColor,
  398 + // List<BoxShadow> boxShadows,
  399 + // Gradient backgroundGradient,
  400 + // FlatButton mainButton,
  401 + // OnTap onTap,
  402 + // bool isDismissible,
  403 + // bool showProgressIndicator,
  404 + // AnimationController progressIndicatorController,
  405 + // Color progressIndicatorBackgroundColor,
  406 + // Animation<Color> progressIndicatorValueColor,
  407 + // SnackStyle snackStyle,
  408 + // Curve forwardAnimationCurve,
  409 + // Curve reverseAnimationCurve,
  410 + // Duration animationDuration,
  411 + // double barBlur,
  412 + // double overlayBlur,
  413 + // Color overlayColor,
  414 + // Form userInputForm
  415 + ///////////////////////////////////
  416 +```
  417 +
  418 +If you prefer the traditional snackbar, or want to customize it from scratch, including adding just one line (Get.snackbar makes use of a mandatory title and message), you can use
  419 +`Get.rawSnackbar();` which provides the RAW API on which Get.snackbar was built.
  420 +
  421 +### Dialogs
  422 +
  423 +To open dialog:
  424 +
  425 +```dart
  426 +Get.dialog(YourDialogWidget());
  427 +```
  428 +
  429 +To open default dialog:
  430 +
  431 +```dart
  432 +Get.defaultDialog(
  433 + onConfirm: () => print("Ok"),
  434 + middleText: "Dialog made in 3 lines of code"
  435 +);
  436 +```
  437 +
  438 +You can also use Get.generalDialog instead of showGeneralDialog.
  439 +
  440 +For all other Flutter dialog widgets, including cupertinos, you can use Get.overlayContext instead of context, and open it anywhere in your code.
  441 +For widgets that don't use Overlay, you can use Get.context.
  442 +These two contexts will work in 99% of cases to replace the context of your UI, except for cases where inheritedWidget is used without a navigation context.
  443 +
  444 +### BottomSheets
  445 +
  446 +Get.bottomSheet is like showModalBottomSheet, but don't need of context.
  447 +
  448 +```dart
  449 +Get.bottomSheet(
  450 + Container(
  451 + child: Wrap(
  452 + children: <Widget>[
  453 + ListTile(
  454 + leading: Icon(Icons.music_note),
  455 + title: Text('Music'),
  456 + onTap: () => {}
  457 + ),
  458 + ListTile(
  459 + leading: Icon(Icons.videocam),
  460 + title: Text('Video'),
  461 + onTap: () => {},
  462 + ),
  463 + ],
  464 + ),
  465 + );
  466 +);
  467 +```
  468 +
  469 +## Nested Navigation
  470 +
  471 +Get made Flutter's nested navigation even easier.
  472 +You don't need the context, and you will find your navigation stack by Id.
  473 +
  474 +- NOTE: Creating parallel navigation stacks can be dangerous. The ideal is not to use NestedNavigators, or to use sparingly. If your project requires it, go ahead, but keep in mind that keeping multiple navigation stacks in memory may not be a good idea for RAM consumption.
  475 +
  476 +See how simple it is:
  477 +
  478 +```dart
  479 +Navigator(
  480 + key: Get.nestedKey(1), // create a key by index
  481 + initialRoute: '/',
  482 + onGenerateRoute: (settings) {
  483 + if (settings.name == '/') {
  484 + return GetPageRoute(
  485 + page: Scaffold(
  486 + appBar: AppBar(
  487 + title: Text("Main"),
  488 + ),
  489 + body: Center(
  490 + child: FlatButton(
  491 + color: Colors.blue,
  492 + onPressed: () {
  493 + Get.toNamed('/second', id:1); // navigate by your nested route by index
  494 + },
  495 + child: Text("Go to second"),
  496 + ),
  497 + ),
  498 + ),
  499 + );
  500 + } else if (settings.name == '/second') {
  501 + return GetPageRoute(
  502 + page: Center(
  503 + child: Scaffold(
  504 + appBar: AppBar(
  505 + title: Text("Main"),
  506 + ),
  507 + body: Center(
  508 + child: Text("second")
  509 + ),
  510 + ),
  511 + ),
  512 + );
  513 + }
  514 + }
  515 +),
  516 +```
  1 +
  2 +# State Management
  3 +
  4 +There are currently several state managers for Flutter. However, most of them involve using ChangeNotifier to update widgets and this is a bad and very bad approach to performance of medium or large applications. You can check in the official Flutter documentation that [ChangeNotifier should be used with 1 or a maximum of 2 listeners](https://api.flutter.dev/flutter/foundation/ChangeNotifier-class.html), making it practically unusable for any application medium or large.
  5 +
  6 +Other state managers are good, but have their nuances:
  7 +
  8 +- BLoC is very safe and efficient, but it is very complex for beginners, which has kept people from developing with Flutter.
  9 +- MobX is easier than BLoC and reactive, almost perfect, I would say, but you need to use a code generator, that for large applications, reduces productivity, since you will need to drink a lot of coffees until your code is ready again after a `flutter clean` (And this is not MobX's fault, but the codegen which is really slow!).
  10 +- Provider uses InheritedWidget to deliver the same listener, as a way of solving the problem reported above with ChangeNotifier, which implies that any access to its ChangeNotifier class must be within the widget tree because of the context to access o Inherited.
  11 +
  12 +Get isn't better or worse than any other state manager, but that you should analyze these points as well as the points below to choose between using Get in pure form (Vanilla), or using it in conjunction with another state manager. Definitely, Get is not the enemy of any other state manager, because Get is a microframework, not just a state manager, and can be used either alone or in conjunction with them.
  13 +
  14 +## Simple State Manager
  15 +
  16 +Get has a state manager that is extremely light and easy, which does not use ChangeNotifier, will meet the need especially for those new to Flutter, and will not cause problems for large applications.
  17 +
  18 +### Advantages
  19 +
  20 +1. Update only the required widgets.
  21 +
  22 +2. Does not use changeNotifier, it is the state manager that uses less memory (close to 0mb).
  23 +
  24 +3. Forget StatefulWidget! With Get you will never need it. With the other state managers, you will probably have to use a StatefulWidget to get the instance of your Provider, BLoC, MobX Controller, etc. But have you ever stopped to think that your appBar, your scaffold, and most of the widgets that are in your class are stateless? So why save the state of an entire class, if you can only save the state of the Widget that is stateful? Get solves that, too. Create a Stateless class, make everything stateless. If you need to update a single component, wrap it with GetBuilder, and its state will be maintained.
  25 +
  26 +4. Organize your project for real! Controllers must not be in your UI, place your TextEditController, or any controller you use within your Controller class.
  27 +
  28 +5. Do you need to trigger an event to update a widget as soon as it is rendered? GetBuilder has the property "initState", just like StatefulWidget, and you can call events from your controller, directly from it, no more events being placed in your initState.
  29 +
  30 +6. Do you need to trigger an action like closing streams, timers and etc? GetBuilder also has the dispose property, where you can call events as soon as that widget is destroyed.
  31 +
  32 +7. Use streams only if necessary. You can use your StreamControllers inside your controller normally, and use StreamBuilder also normally, but remember, a stream reasonably consumes memory, reactive programming is beautiful, but you shouldn't abuse it. 30 streams open simultaneously can be worse than changeNotifier (and changeNotifier is very bad).
  33 +
  34 +8. Update widgets without spending ram for that. Get stores only the GetBuilder creator ID, and updates that GetBuilder when necessary. The memory consumption of the get ID storage in memory is very low even for thousands of GetBuilders. When you create a new GetBuilder, you are actually sharing the state of GetBuilder that has a creator ID. A new state is not created for each GetBuilder, which saves A LOT OF ram for large applications. Basically your application will be entirely Stateless, and the few Widgets that will be Stateful (within GetBuilder) will have a single state, and therefore updating one will update them all. The state is just one.
  35 +
  36 +9. Get is omniscient and in most cases it knows exactly the time to take a controller out of memory. You should not worry about when to dispose of a controller, Get knows the best time to do this.
  37 +
  38 +### Usage
  39 +
  40 +```dart
  41 +// Create controller class and extends GetxController
  42 +class Controller extends GetxController {
  43 + int counter = 0;
  44 + void increment() {
  45 + counter++;
  46 + update(); // use update() to update counter variable on UI when increment be called
  47 + }
  48 +}
  49 +// On your Stateless/Stateful class, use GetBuilder to update Text when increment be called
  50 +GetBuilder<Controller>(
  51 + init: Controller(), // INIT IT ONLY THE FIRST TIME
  52 + builder: (_) => Text(
  53 + '${_.counter}',
  54 + ),
  55 +)
  56 +//Initialize your controller only the first time. The second time you are using ReBuilder for the same controller, do not use it again. Your controller will be automatically removed from memory as soon as the widget that marked it as 'init' is deployed. You don't have to worry about that, Get will do it automatically, just make sure you don't start the same controller twice.
  57 +```
  58 +
  59 +**Done!**
  60 +
  61 +- You have already learned how to manage states with Get.
  62 +
  63 +- Note: You may want a larger organization, and not use the init property. For that, you can create a class and extends Bindings class, and within it mention the controllers that will be created within that route. Controllers will not be created at that time, on the contrary, this is just a statement, so that the first time you use a Controller, Get will know where to look. Get will remain lazyLoad, and will continue to dispose Controllers when they are no longer needed. See the pub.dev example to see how it works.
  64 +
  65 +If you navigate many routes and need data that was in your previously used controller, you just need to use GetBuilder Again (with no init):
  66 +
  67 +```dart
  68 +class OtherClass extends StatelessWidget {
  69 + @override
  70 + Widget build(BuildContext context) {
  71 + return Scaffold(
  72 + body: Center(
  73 + child: GetBuilder<Controller>(
  74 + builder: (s) => Text('${s.counter}'),
  75 + ),
  76 + ),
  77 + );
  78 + }
  79 +
  80 +```
  81 +
  82 +If you need to use your controller in many other places, and outside of GetBuilder, just create a get in your controller and have it easily. (or use `Get.find<Controller>()`)
  83 +
  84 +```dart
  85 +class Controller extends GetxController {
  86 +
  87 + /// You do not need that. I recommend using it just for ease of syntax.
  88 + /// with static method: Controller.to.counter();
  89 + /// with no static method: Get.find<Controller>().counter();
  90 + /// There is no difference in performance, nor any side effect of using either syntax. Only one does not need the type, and the other the IDE will autocomplete it.
  91 + static Controller get to => Get.find(); // add this line
  92 +
  93 + int counter = 0;
  94 + void increment() {
  95 + counter++;
  96 + update();
  97 + }
  98 +}
  99 +```
  100 +
  101 +And then you can access your controller directly, that way:
  102 +
  103 +```dart
  104 +FloatingActionButton(
  105 + onPressed: () {
  106 + Controller.to.increment(),
  107 + } // This is incredibly simple!
  108 + child: Text("${Controller.to.counter}"),
  109 +),
  110 +```
  111 +
  112 +When you press FloatingActionButton, all widgets that are listening to the 'counter' variable will be updated automatically.
  113 +
  114 +### How it handles controllers
  115 +
  116 +Let's say we have this:
  117 +
  118 +`Class a => Class B (has controller X) => Class C (has controller X)`
  119 +
  120 +In class A the controller is not yet in memory, because you have not used it yet (Get is lazyLoad). In class B you used the controller, and it entered memory. In class C you used the same controller as in class B, Get will share the state of controller B with controller C, and the same controller is still in memory. If you close screen C and screen B, Get will automatically take controller X out of memory and free up resources, because Class a is not using the controller. If you navigate to B again, controller X will enter memory again, if instead of going to class C, you return to class A again, Get will take the controller out of memory in the same way. If class C didn't use the controller, and you took class B out of memory, no class would be using controller X and likewise it would be disposed of. The only exception that can mess with Get, is if you remove B from the route unexpectedly, and try to use the controller in C. In this case, the creator ID of the controller that was in B was deleted, and Get was programmed to remove it from memory every controller that has no creator ID. If you intend to do this, add the "autoRemove: false" flag to class B's GetBuilder and use adoptID = true; in class C's GetBuilder.
  121 +
  122 +### You won't need StatefulWidgets anymore
  123 +
  124 +Using StatefulWidgets means storing the state of entire screens unnecessarily, even because if you need to minimally rebuild a widget, you will embed it in a Consumer/Observer/BlocProvider/GetBuilder/GetX/Obx, which will be another StatefulWidget.
  125 +The StatefulWidget class is a class larger than StatelessWidget, which will allocate more RAM, and this may not make a significant difference between one or two classes, but it will most certainly do when you have 100 of them!
  126 +Unless you need to use a mixin, like TickerProviderStateMixin, it will be totally unnecessary to use a StatefulWidget with Get.
  127 +
  128 +You can call all methods of a StatefulWidget directly from a GetBuilder.
  129 +If you need to call initState() or dispose() method for example, you can call them directly;
  130 +
  131 +```dart
  132 +GetBuilder<Controller>(
  133 + initState: (_) => Controller.to.fetchApi(),
  134 + dispose: (_) => Controller.to.closeStreams(),
  135 + builder: (s) => Text('${s.username}'),
  136 +),
  137 +```
  138 +
  139 +A much better approach than this is to use the onInit() and onClose() method directly from your controller.
  140 +
  141 +```dart
  142 +@override
  143 +void onInit() {
  144 + fetchApi();
  145 + super.onInit();
  146 +}
  147 +```
  148 +
  149 +- NOTE: If you want to start a method at the moment the controller is called for the first time, you DON'T NEED to use constructors for this, in fact, using a performance-oriented package like Get, this borders on bad practice, because it deviates from the logic in which the controllers are created or allocated (if you create an instance of this controller, the constructor will be called immediately, you will be populating a controller before it is even used, you are allocating memory without it being in use, this definitely hurts the principles of this library). The onInit() methods; and onClose(); were created for this, they will be called when the Controller is created, or used for the first time, depending on whether you are using Get.lazyPut or not. If you want, for example, to make a call to your API to populate data, you can forget about the old-fashioned method of initState/dispose, just start your call to the api in onInit, and if you need to execute any command like closing streams, use the onClose() for that.
  150 +
  151 +### Why it exists
  152 +
  153 +The purpose of this package is precisely to give you a complete solution for navigation of routes, management of dependencies and states, using the least possible dependencies, with a high degree of decoupling. Get engages all high and low level Flutter APIs within itself, to ensure that you work with the least possible coupling. We centralize everything in a single package, to ensure that you don't have any kind of coupling in your project. That way, you can put only widgets in your view, and leave the part of your team that works with the business logic free, to work with the business logic without depending on any element of the View. This provides a much cleaner working environment, so that part of your team works only with widgets, without worrying about sending data to your controller, and part of your team works only with the business logic in its breadth, without depending on no element of the view.
  154 +
  155 +So to simplify this:
  156 +You don't need to call methods in initState and send them by parameter to your controller, nor use your controller constructor for that, you have the onInit() method that is called at the right time for you to start your services.
  157 +You do not need to call the device, you have the onClose() method that will be called at the exact moment when your controller is no longer needed and will be removed from memory. That way, leave views for widgets only, refrain from any kind of business logic from it.
  158 +
  159 +Do not call a dispose method inside GetxController, it will not do anything, remember that the controller is not a Widget, you should not "dispose" it, and it will be automatically and intelligently removed from memory by Get. If you used any stream on it and want to close it, just insert it into the close method. Example:
  160 +
  161 +```dart
  162 +class Controller extends GetxController {
  163 + StreamController<User> user = StreamController<User>();
  164 + StreamController<String> name = StreamController<String>();
  165 +
  166 + /// close stream = onClose method, not dispose.
  167 + @override
  168 + void onClose() {
  169 + user.close();
  170 + name.close();
  171 + super.onClose();
  172 + }
  173 +}
  174 +```
  175 +
  176 +Controller life cycle:
  177 +
  178 +- onInit() where it is created.
  179 +- onClose() where it is closed to make any changes in preparation for the delete method
  180 +- deleted: you do not have access to this API because it is literally removing the controller from memory. It is literally deleted, without leaving any trace.
  181 +
  182 +### Other ways of using it
  183 +
  184 +You can use Controller instance directly on GetBuilder value:
  185 +
  186 +```dart
  187 +GetBuilder<Controller>(
  188 + init: Controller(),
  189 + builder: (value) => Text(
  190 + '${value.counter}', //here
  191 + ),
  192 +),
  193 +```
  194 +
  195 +You may also need an instance of your controller outside of your GetBuilder, and you can use these approaches to achieve this:
  196 +
  197 +```dart
  198 +class Controller extends GetxController {
  199 + static Controller get to => Get.find();
  200 +[...]
  201 +}
  202 +// on you view:
  203 +GetBuilder<Controller>(
  204 + init: Controller(), // use it only first time on each controller
  205 + builder: (_) => Text(
  206 + '${Controller.to.counter}', //here
  207 + )
  208 +),
  209 +```
  210 +
  211 +or
  212 +
  213 +```dart
  214 +class Controller extends GetxController {
  215 + // static Controller get to => Get.find(); // with no static get
  216 +[...]
  217 +}
  218 +// on stateful/stateless class
  219 +GetBuilder<Controller>(
  220 + init: Controller(), // use it only first time on each controller
  221 + builder: (_) => Text(
  222 + '${Get.find<Controller>().counter}', //here
  223 + ),
  224 +),
  225 +```
  226 +
  227 +- You can use "non-canonical" approaches to do this. If you are using some other dependency manager, like get_it, modular, etc., and just want to deliver the controller instance, you can do this:
  228 +
  229 +```dart
  230 +Controller controller = Controller();
  231 +[...]
  232 +GetBuilder<Controller>(
  233 + init: controller, //here
  234 + builder: (_) => Text(
  235 + '${controller.counter}', // here
  236 + ),
  237 +),
  238 +
  239 +```
  240 +
  241 +### Unique IDs
  242 +
  243 +If you want to refine a widget's update control with GetBuilder, you can assign them unique IDs:
  244 +
  245 +```dart
  246 +GetBuilder<Controller>(
  247 + id: 'text'
  248 + init: Controller(), // use it only first time on each controller
  249 + builder: (_) => Text(
  250 + '${Get.find<Controller>().counter}', //here
  251 + ),
  252 +),
  253 +```
  254 +
  255 +And update it this form:
  256 +
  257 +```dart
  258 +update(['text']);
  259 +```
  260 +
  261 +You can also impose conditions for the update:
  262 +
  263 +```dart
  264 +update(['text'], counter < 10);
  265 +```
  266 +
  267 +GetX does this automatically and only reconstructs the widget that uses the exact variable that was changed, if you change a variable to the same as the previous one and that does not imply a change of state , GetX will not rebuild the widget to save memory and CPU cycles (3 is being displayed on the screen, and you change the variable to 3 again. In most state managers, this will cause a new rebuild, but with GetX the widget will only is rebuilt again, if in fact his state has changed).
  268 +
  269 +## Reactive State Manager
  270 +
  271 +Reactive programming can alienate many people because it is said to be complicated. Getx turns reactive programming into something so simple, that it can be used and learned by those who started at that very moment in Flutter. No, you will not need to create StreamControllers. You also won't need to create a StreamBuilder for each variable. You will not need to create a class for each state. You will not need to create a get for an initial value. Reactive programming with Get is as easy as using setState (or even easier!).
  272 +
  273 +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.
  274 +
  275 +This is your count variable:
  276 +
  277 +```dart
  278 +var name = 'Jonatas Borges';
  279 +```
  280 +
  281 +To make it observable, you just need to add ".obs" to the end of it:
  282 +
  283 +```dart
  284 +var name = 'Jonatas Borges'.obs;
  285 +```
  286 +
  287 +This borders on absurdity when it comes to practicality. What did we do under the hood? We created a stream of Strings, assigned the initial value "Jonatas Borges", we warn all widgets that use "Jonatas Borges" that they now belong to this variable, and when it is changed, they will be changed too. This is the magic of Get, that only dart allows us to do this.
  288 +
  289 +Okay, but as we know, a widget can only be changed if it is inside a function, because static classes do not have the power to "auto-change". You will need to create a StreamBuilder, subscribe to listen to this variable, and create a "cascade" of StreamBuilder if you want to change several variables in the same scope, right?
  290 +No, you don't need a StreamBuilder, but you are right about static classes.
  291 +
  292 +Well, in the view we usually have a lot of boilerplate when we want to change a specific widget. With Get you can also forget about this Boilerplate. StreamBuilder? initialValue? builder?
  293 +No, you just need to play this variable inside an Obx widget.
  294 +
  295 +```dart
  296 +Obx (() => Text (controller.name));
  297 +```
  298 +
  299 +What do you need to memorize? "Obx(() =>" You are just passing that widget through an arrow-function into an Obx. Obx is smart, and will only be changed if the value of name is changed. If name is "John" and you change it to "John", it will not have any changes on the screen, and Obx will simply ignore this change, and will not rebuild the widget, to save resources. Isn't that amazing?
  300 +
  301 +What if I have 5 observable variables within an Obx? It will update when any of them are changed. And if I have 30 variables in a class, when I update one, will it update all variables that are in that class? No, just the specific widget that uses that variable. And if I machine-gun my observable variable 1 billion times with the same value, will I have freeze on the screen for unnecessary reconstructions? No, GetX only updates the screen when the variable changes on the screen, if the screen remains the same, it will not reconstruct anything.
  302 +
  303 +### Advantages
  304 +
  305 +GetBuilder is aimed precisely at multiple state control. Imagine that you added 30 products to a cart, you click delete one, at the same time that the list is updated, the price is updated and the badge in the shopping cart is updated to a smaller number. This type of approach makes GetBuilder killer, because it groups states and changes them all at once without any "computational logic" for that. GetBuilder was created with this type of situation in mind, since for ephemeral change of state, you can use setState and you would not need a state manager for this. However, there are situations where you want only the widget where a certain variable has been changed to be rebuilt, and this is what GetX does with a mastery never seen before.
  306 +
  307 +That way, if you want an individual controller, you can assign IDs for that, or use GetX. This is up to you, remembering that the more "individual" widgets you have, the more the performance of GetX will stand out, while the performance of GetBuilder should be superior, when there is multiple change of state.
  308 +
  309 +You can use both in any situation, but if you want to tune their application to the maximum possible performance, I would say that: if your variables are changed at different times, use GetX, because there is no competition for it when the subject is to rebuild only what is necessary, if you do not need unique IDs, because all your variables will be changed when you perform an action, use GetBuilder, because it is a simple state updater in blocks, made in a few lines of code, to make just what he promises to do: update state in blocks. There is no way to compare RAM, CPU, or anything else from a giant state manager to a simple StatefulWidget (like GetBuilder) that is updated when you call update(). It was done in a simple way, to have the least computational logic involved, just to fulfill a single purpose and spend the minimum resources possible for that purpose.
  310 +If you want a powerful state manager, you can go without fear to GetX. It does not work with variables, but flows, everything in it is streams under the hood. You can use rxDart in conjunction with it, because everything is stream, you can hear the event of each "variable", because everything in it is stream, it is literally BLoC, easier than MobX, and without code generator or decorations .
  311 +
  312 +If you want power, Get gives you the most advanced state manager you could ever have.
  313 +GetX was built 100% based on Streams, and give you all the firepower that BLoC gave you, with an easier facility than using MobX.
  314 +Without decorations, you can turn anything into Observable with just a ".obs".
  315 +
  316 +Maximum performance: In addition to having a smart algorithm for minimal reconstruction, Get uses comparators to make sure the state has changed. If you experience any errors in your application, and send a duplicate change of state, Get will ensure that your application does not collapse.
  317 +The state only changes if the values ​​change. That's the main difference between Get, and using Computed from MobX. When joining two observables, when one is changed, the hearing of that observable will change. With Get, if you join two variables (which is unnecessary computed for that), GetX (similar to Observer) will only change if it implies a real change of state.
  318 +
  319 +### Usage
  320 +
  321 +You have 3 ways to turn a variable into an observable.
  322 +The first is using Rx{Type}.
  323 +
  324 +```dart
  325 +var count = RxString();
  326 +```
  327 +
  328 +The second is to use Rx and type it with `Rx<Type>`
  329 +
  330 +```dart
  331 +var count = Rx<String>();
  332 +```
  333 +
  334 +The third, more practical, easy, and incredible approach, is just to add an .obs to your variable.
  335 +
  336 +```dart
  337 +var count = 0.obs;
  338 +
  339 +// or Rxint count = 0.obs;
  340 +// or Rx<int> count = 0.obs;
  341 +```
  342 +
  343 + As we know, Dart is now heading towards null safety. With that it is a good idea, from now on, you start to use your variables always with an initial value. Transforming a variable into an observable with an initial value with Get is the simplest and most practical approach that currently exists in Flutter. You will literally add a ".obs" to the end of your variable, and that’s it, you’ve made it observable, and its value will be the initial value, this is fantastic!
  344 +
  345 +You can add variables, and if you want to type your widget to get your controller inside, you just need to use GetX widget instead of Obx
  346 +
  347 +```dart
  348 +final count1 = 0.obs;
  349 +final count2 = 0.obs;
  350 +int get sum => count1.value + count2.value;
  351 +```
  352 +
  353 +```dart
  354 +GetX<Controller>(
  355 + builder: (value) {
  356 + print("count 1 rebuild");
  357 + return Text('${value.count1.value}');
  358 + },
  359 +),
  360 +GetX<Controller>(
  361 + builder: (_) {
  362 + print("count 2 rebuild");
  363 + return Text('${_.count2.value}');
  364 + },
  365 +),
  366 +GetX<Controller>(
  367 + builder: (_) {
  368 + print("count 3 rebuild");
  369 + return Text('${_.sum}');
  370 + },
  371 +),
  372 +```
  373 +
  374 +If we increment the number of count 1, only count 1 and count 3 are reconstructed, because count 1 now has a value of 1, and 1 + 0 = 1, changing the sum value.
  375 +
  376 +If we change count 2, only count2 and 3 are reconstructed, because the value of 2 has changed, and the result of the sum is now 2.
  377 +
  378 +If we add the number 1 to count 1, which already contains 1, no widget is reconstructed. If we add a value of 1 for count 1 and a value of 2 for count 2, only 2 and 3 will be reconstructed, simply because GetX not only changes what is necessary, it avoids duplicating events.
  379 +
  380 +- NOTE: By default, the first event will allow rebuild even if it is the same. We created this behavior due to dualistic variables, such as Boolean.
  381 +Imagine you did this:
  382 +
  383 +```dart
  384 +var isLogged = false.obs;
  385 +```
  386 +
  387 +and then you check if a user is logged in to trigger an event in "ever".
  388 +
  389 +```dart
  390 +onInit(){
  391 + ever(isLogged, fireRoute);
  392 + isLogged.value = await Preferences.hasToken();
  393 +}
  394 +
  395 +fireRoute(logged) {
  396 + if (logged) {
  397 + Get.off(Home());
  398 + } else {
  399 + Get.off(Login());
  400 + }
  401 +}
  402 +```
  403 +
  404 +if hasToken was false, there would be no change to isLogged, so ever would never be called. To avoid this type of behavior, the first change to an observable will always trigger an event, even if it is the same.
  405 +You can remove this behavior if you want, using:
  406 +`isLogged.firstRebuild = false;`
  407 +
  408 +In addition, Get provides refined state control. You can condition an event (such as adding an object to a list), on a certain condition.
  409 +
  410 +```dart
  411 +list.addIf(item<limit, item);
  412 +```
  413 +
  414 +Without decorations, without a code generator, without complications, GetX will change the way you manage your states in Flutter, and that is not a promise, it is a certainty!
  415 +
  416 +Do you know Flutter's counter app? Your Controller class might look like this:
  417 +
  418 +```dart
  419 +class CountCtl extends GetxController {
  420 + final count = 0.obs;
  421 +}
  422 +```
  423 +
  424 +With a simple:
  425 +
  426 +```dart
  427 +ctl.count.value++
  428 +```
  429 +
  430 +You could update the counter variable in your UI, regardless of where it is stored.
  431 +
  432 +### Where .obs can be used
  433 +
  434 +You can transform anything on obs:
  435 +
  436 +```dart
  437 +class RxUser {
  438 + final name = "Camila".obs;
  439 + final age = 18.obs;
  440 +}
  441 +
  442 +class User {
  443 + User({String name, int age});
  444 + final rx = RxUser();
  445 +
  446 + String get name => rx.name.value;
  447 + set name(String value) => rx.name.value = value;
  448 +
  449 + int get age => rx.age.value;
  450 + set age(int value) => rx.age.value = value;
  451 +}
  452 +```
  453 +
  454 +```dart
  455 +
  456 +void main() {
  457 + final user = User();
  458 + print(user.name);
  459 + user.age = 23;
  460 + user.rx.age.listen((int age) => print(age));
  461 + user.age = 24;
  462 + user.age = 25;
  463 +}
  464 +___________
  465 +out:
  466 +Camila
  467 +23
  468 +24
  469 +25
  470 +
  471 +```
  472 +
  473 +### Note about Lists
  474 +
  475 +Working with Lists using Get is the best and most enjoyable thing in the world. They are completely observable as are the objects within it. That way, if you add a value to a list, it will automatically rebuild the widgets that use it.
  476 +You also don't need to use ".value" with lists, the amazing dart api allowed us to remove that, unfortunate primitive types like String and int cannot be extended, making the use of .value mandatory, but that won't be a problem if you work with gets and setters for these.
  477 +
  478 +```dart
  479 +final list = List<User>().obs;
  480 +```
  481 +
  482 +```dart
  483 +ListView.builder (
  484 + itemCount: list.lenght
  485 +)
  486 +```
  487 +
  488 +You don't have to work with sets if you don't want to. you can use the "assign 'and" assignAll "api.
  489 +The "assign" api will clear your list, and add a single object that you want to start there.
  490 +The "assignAll" api will clear the existing list and add any iterable objects that you inject into it.
  491 +
  492 +### Why i have to use .value
  493 +
  494 +We could remove the obligation to use 'value' to String and int with a simple decoration and code generator, but the purpose of this lib is precisely not to need any external dependency. It is to offer an environment ready for programming, involving the essentials (management of routes, dependencies and states), in a simple, light and performance way without needing any external package. You can literally add 3 letters to your pubspec (get) and start programming. All solutions included by default, from route management to state management, aim at ease, productivity and performance. The total weight of this library is less than that of a single state manager, even though it is a complete solution, and that is what you must understand. If you are bothered by value, and like a code generator, MobX is a great alternative, and you can use it in conjunction with Get. For those who want to add a single dependency in pubspec and start programming without worrying about the version of a package being incompatible with another, or if the error of a state update is coming from the state manager or dependency, or still, do not want to worrying about the availability of controllers, whether literally "just programming", get is just perfect.
  495 +
  496 +If you have no problem with the MobX code generator, or have no problem with the BLoC boilerplate, you can simply use Get for routes, and forget that it has state manager. Get SEM and RSM were born out of necessity, my company had a project with more than 90 controllers, and the code generator simply took more than 30 minutes to complete its tasks after a Flutter Clean on a reasonably good machine, if your project it has 5, 10, 15 controllers, any state manager will supply you well. If you have an absurdly large project, and code generator is a problem for you, you have been awarded this solution.
  497 +
  498 +Obviously, if someone wants to contribute to the project and create a code generator, or something similar, I will link in this readme as an alternative, my need is not the need for all devs, but for now I say, there are good solutions that already do that, like MobX.
  499 +
  500 +### Obx()
  501 +
  502 +Typing in Get using Bindings is unnecessary. you can use the Obx widget instead of GetX which only receives the anonymous function that creates a widget.
  503 +Obviously, if you don't use a type, you will need to have an instance of your controller to use the variables, or use `Get.find<Controller>()` .value or Controller.to.value to retrieve the value.
  504 +
  505 +### Workers
  506 +
  507 +Workers will assist you, triggering specific callbacks when an event occurs.
  508 +
  509 +```dart
  510 +/// Called every time the variable $_ is changed
  511 +ever(count1, (_) => print("$_ has been changed"));
  512 +
  513 +/// Called only first time the variable $_ is changed
  514 +once(count1, (_) => print("$_ was changed once"));
  515 +
  516 +/// Anti DDos - Called every time the user stops typing for 1 second, for example.
  517 +debounce(count1, (_) => print("debouce$_"), time: Duration(seconds: 1));
  518 +
  519 +/// Ignore all changes within 1 second.
  520 +interval(count1, (_) => print("interval $_"), time: Duration(seconds: 1));
  521 +```
  522 +
  523 +- ever
  524 +'ever' is called every time its variable is changed. That's it.
  525 +
  526 +- ever
  527 +'once' is called only the first time the variable has been changed.
  528 +
  529 +- debounce
  530 +'debounce' is very useful in search functions, where you only want the API to be called when the user finishes typing. If the user types "Jonny", you will have 5 searches in the APIs, by the letter J, o, n, n, and y. With Get this does not happen, because you will have a "debounce" Worker that will only be triggered at the end of typing.
  531 +
  532 +- interval
  533 +'interval' is different from the debouce. debouce if the user makes 1000 changes to a variable within 1 second, he will send only the last one after the stipulated timer (the default is 800 milliseconds). Interval will instead ignore all user actions for the stipulated period. If you send events for 1 minute, 1000 per second, debounce will only send you the last one, when the user stops strafing events. interval will deliver events every second, and if set to 3 seconds, it will deliver 20 events that minute. This is recommended to avoid abuse, in functions where the user can quickly click on something and get some advantage (imagine that the user can earn coins by clicking on something, if he clicked 300 times in the same minute, he would have 300 coins, using interval, you you can set a time frame for 3 seconds, and even then clicking 300 or a thousand times, the maximum he would get in 1 minute would be 20 coins, clicking 300 or 1 million times). The debounce is suitable for anti-DDos, for functions like search where each change to onChange would cause a query to your api. Debounce will wait for the user to stop typing the name, to make the request. If it were used in the coin scenario mentioned above, the user would only win 1 coin, because it is only executed, when the user "pauses" for the established time.
  534 +
  535 +## Mixing the two state managers
  536 +
  537 +Some people opened a feature request, as they wanted to use only one type of reactive variable, and the other mechanics, and needed to insert an Obx into a GetBuilder for this. Thinking about it MixinBuilder was created. It allows both reactive changes by changing ".obs" variables, and mechanical updates via update(). However, of the 4 widgets he is the one that consumes the most resources, since in addition to having a Subscription to receive change events from his children, he subscribes to the update method of his controller.
  538 +
  539 +Extending GetxController is important, as they have life cycles, and can "start" and "end" events in their onInit() and onClose() methods. You can use any class for this, but I strongly recommend you use the GetxController class to place your variables, whether they are observable or not.
  540 +
  541 +## GetBuilder vs GetX vs Obx vs MixinBuilder
  542 +
  543 +In a decade working with programming I was able to learn some valuable lessons.
  544 +
  545 +My first contact with reactive programming was so "wow, this is incredible" and in fact reactive programming is incredible.
  546 +However, it is not suitable for all situations. Often all you need is to change the state of 2 or 3 widgets at the same time, or an ephemeral change of state, in which case reactive programming is not bad, but it is not appropriate.
  547 +
  548 +Reactive programming has a higher consumption of RAM consumption that can be compensated for by the individual workflow, which will ensure that only one widget is rebuilt and when necessary, but creating a list with 80 objects, each with several streams is not a good one idea. Open the dart inspect and check how much a StreamBuilder consumes, and you'll understand what I'm trying to tell you.
  549 +
  550 +With that in mind, I created the simple state manager. It is simple, and that is exactly what you should demand from it: updating state in blocks in a simple way, and in the most economical way.
  551 +
  552 +GetBuilder is very economical in RAM, and there is hardly a more economical approach than him (at least I can't imagine one, if it exists, please let us know).
  553 +
  554 +However, GetBuilder is still a mechanical state manager, you need to call update() just like you would need to call Provider's notifyListeners().
  555 +
  556 +There are other situations where reactive programming is really interesting, and not working with it is the same as reinventing the wheel. With that in mind, GetX was created to provide everything that is most modern and advanced in a state manager. It updates only what is necessary and when necessary, if you have an error and send 300 state changes simultaneously, GetX will filter and update the screen only if the state actually changes.
  557 +
  558 +GetX is still more economical than any other reactive state manager, but it consumes a little more RAM than GetBuilder. Thinking about it and aiming to maximize the consumption of resources that Obx was created. Unlike GetX and GetBuilder, you will not be able to initialize a controller inside an Obx, it is just a Widget with a StreamSubscription that receives change events from your children, that's all. It is more economical than GetX, but loses to GetBuilder, which was to be expected, since it is reactive, and GetBuilder has the most simplistic approach that exists, of storing a widget's hashcode and its StateSetter. With Obx you don't need to write your controller type, and you can hear the change from multiple different controllers, but it needs to be initialized before, either using the example approach at the beginning of this readme, or using the Bindings class.