Nipodemos

correct indentation on original readme file

Showing 1 changed file with 48 additions and 40 deletions
@@ -20,7 +20,7 @@ Navigator.of(context).push( @@ -20,7 +20,7 @@ Navigator.of(context).push(
20 return Home(); 20 return Home();
21 }, 21 },
22 ), 22 ),
23 - ); 23 +);
24 24
25 // Get syntax 25 // Get syntax
26 Get.to(Home()); 26 Get.to(Home());
@@ -130,7 +130,7 @@ Navigator.of(context).push( @@ -130,7 +130,7 @@ Navigator.of(context).push(
130 return HomePage(); 130 return HomePage();
131 }, 131 },
132 ), 132 ),
133 - ); 133 +);
134 134
135 // Get using Flutter syntax without needing context 135 // Get using Flutter syntax without needing context
136 navigator.push( 136 navigator.push(
@@ -139,7 +139,7 @@ navigator.push( @@ -139,7 +139,7 @@ navigator.push(
139 return HomePage(); 139 return HomePage();
140 }, 140 },
141 ), 141 ),
142 - ); 142 +);
143 143
144 // Get syntax (It is much better, but you have the right to disagree) 144 // Get syntax (It is much better, but you have the right to disagree)
145 Get.to(HomePage()); 145 Get.to(HomePage());
@@ -157,9 +157,10 @@ final snackBar = SnackBar( @@ -157,9 +157,10 @@ final snackBar = SnackBar(
157 label: 'I am a old and ugly snackbar :(', 157 label: 'I am a old and ugly snackbar :(',
158 onPressed: (){} 158 onPressed: (){}
159 ), 159 ),
160 - // Find the Scaffold in the widget tree and use  
161 - // it to show a SnackBar.  
162 - Scaffold.of(context).showSnackBar(snackBar); 160 +);
  161 +// Find the Scaffold in the widget tree and use
  162 +// it to show a SnackBar.
  163 +Scaffold.of(context).showSnackBar(snackBar);
163 ``` 164 ```
164 165
165 With Get: 166 With Get:
@@ -171,7 +172,7 @@ Get.snackbar('Hi', 'i am a modern snackbar'); @@ -171,7 +172,7 @@ Get.snackbar('Hi', 'i am a modern snackbar');
171 With Get, all you have to do is call your Get.snackbar from anywhere in your code or customize it however you want! 172 With Get, all you have to do is call your Get.snackbar from anywhere in your code or customize it however you want!
172 173
173 ```dart 174 ```dart
174 - Get.snackbar( 175 +Get.snackbar(
175 "Hey i'm a Get SnackBar!", // title 176 "Hey i'm a Get SnackBar!", // title
176 "It's unbelievable! I'm using SnackBar without context, without boilerplate, without Scaffold, it is something truly amazing!", // message 177 "It's unbelievable! I'm using SnackBar without context, without boilerplate, without Scaffold, it is something truly amazing!", // message
177 icon: Icon(Icons.alarm), 178 icon: Icon(Icons.alarm),
@@ -180,7 +181,7 @@ With Get, all you have to do is call your Get.snackbar from anywhere in your cod @@ -180,7 +181,7 @@ With Get, all you have to do is call your Get.snackbar from anywhere in your cod
180 barBlur: 20, 181 barBlur: 20,
181 isDismissible: true, 182 isDismissible: true,
182 duration: Duration(seconds: 3), 183 duration: Duration(seconds: 3),
183 - ); 184 +);
184 185
185 186
186 ////////// ALL FEATURES ////////// 187 ////////// ALL FEATURES //////////
@@ -233,9 +234,10 @@ Get.dialog(YourDialogWidget()); @@ -233,9 +234,10 @@ Get.dialog(YourDialogWidget());
233 To open default dialog: 234 To open default dialog:
234 235
235 ```dart 236 ```dart
236 - Get.defaultDialog( 237 +Get.defaultDialog(
237 onConfirm: () => print("Ok"), 238 onConfirm: () => print("Ok"),
238 - middleText: "Dialog made in 3 lines of code"); 239 + middleText: "Dialog made in 3 lines of code"
  240 +);
239 ``` 241 ```
240 You can also use Get.generalDialog instead of showGeneralDialog. 242 You can also use Get.generalDialog instead of showGeneralDialog.
241 243
@@ -264,8 +266,7 @@ Get.bottomSheet( @@ -264,8 +266,7 @@ Get.bottomSheet(
264 ], 266 ],
265 ), 267 ),
266 ); 268 );
267 - }  
268 - ); 269 +);
269 ``` 270 ```
270 271
271 ## Simple State Manager 272 ## Simple State Manager
@@ -315,7 +316,8 @@ GetBuilder<Controller>( @@ -315,7 +316,8 @@ GetBuilder<Controller>(
315 init: Controller(), // INIT IT ONLY THE FIRST TIME 316 init: Controller(), // INIT IT ONLY THE FIRST TIME
316 builder: (_) => Text( 317 builder: (_) => Text(
317 '${_.counter}', 318 '${_.counter}',
318 - )), 319 + ),
  320 +)
319 //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. 321 //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.
320 ``` 322 ```
321 **Done!** 323 **Done!**
@@ -327,7 +329,7 @@ GetBuilder<Controller>( @@ -327,7 +329,7 @@ GetBuilder<Controller>(
327 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): 329 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):
328 330
329 ```dart 331 ```dart
330 -class OtherClasse extends StatelessWidget { 332 +class OtherClass extends StatelessWidget {
331 @override 333 @override
332 Widget build(BuildContext context) { 334 Widget build(BuildContext context) {
333 return Scaffold( 335 return Scaffold(
@@ -361,11 +363,11 @@ class Controller extends GetController { @@ -361,11 +363,11 @@ class Controller extends GetController {
361 And then you can access your controller directly, that way: 363 And then you can access your controller directly, that way:
362 ```dart 364 ```dart
363 FloatingActionButton( 365 FloatingActionButton(
364 - onPressed:(){ 366 + onPressed: () {
365 Controller.to.increment(), 367 Controller.to.increment(),
366 } // This is incredibly simple! 368 } // This is incredibly simple!
367 child: Text("${Controller.to.counter}"), 369 child: Text("${Controller.to.counter}"),
368 - ), 370 +),
369 ``` 371 ```
370 When you press FloatingActionButton, all widgets that are listening to the 'counter' variable will be updated automatically. 372 When you press FloatingActionButton, all widgets that are listening to the 'counter' variable will be updated automatically.
371 373
@@ -379,10 +381,10 @@ If you need to call initState() or dispose() method for example, you can call th @@ -379,10 +381,10 @@ If you need to call initState() or dispose() method for example, you can call th
379 381
380 ```dart 382 ```dart
381 GetBuilder<Controller>( 383 GetBuilder<Controller>(
382 - initState(_) => Controller.to.fetchApi(),  
383 - dispose(_) => Controller.to.closeStreams(), 384 + initState: (_) => Controller.to.fetchApi(),
  385 + dispose: (_) => Controller.to.closeStreams(),
384 builder: (s) => Text('${s.username}'), 386 builder: (s) => Text('${s.username}'),
385 - ), 387 +),
386 ``` 388 ```
387 389
388 A much better approach than this is to use the onInit() and onClose() method directly from your controller. 390 A much better approach than this is to use the onInit() and onClose() method directly from your controller.
@@ -406,17 +408,17 @@ Do not call a dispose method inside GetController, it will not do anything, reme @@ -406,17 +408,17 @@ Do not call a dispose method inside GetController, it will not do anything, reme
406 408
407 ```dart 409 ```dart
408 class Controller extends GetController { 410 class Controller extends GetController {
409 -StreamController<User> user = StreamController<User>();  
410 -StreamController<String> name = StreamController<String>(); 411 + StreamController<User> user = StreamController<User>();
  412 + StreamController<String> name = StreamController<String>();
411 413
412 -/// close stream = onClose method, not dispose.  
413 -@override  
414 -void onClose() { 414 + /// close stream = onClose method, not dispose.
  415 + @override
  416 + void onClose() {
415 user.close(); 417 user.close();
416 name.close(); 418 name.close();
417 super.onClose(); 419 super.onClose();
  420 + }
418 } 421 }
419 -  
420 ``` 422 ```
421 Controller life cycle: 423 Controller life cycle:
422 - onInit() where it is created. 424 - onInit() where it is created.
@@ -434,7 +436,8 @@ GetBuilder<Controller>( @@ -434,7 +436,8 @@ GetBuilder<Controller>(
434 init: Controller(), 436 init: Controller(),
435 builder: (value) => Text( 437 builder: (value) => Text(
436 '${value.counter}', //here 438 '${value.counter}', //here
437 - )), 439 + ),
  440 +),
438 ``` 441 ```
439 You may also need an instance of your controller outside of your GetBuilder, and you can use these approaches to achieve this: 442 You may also need an instance of your controller outside of your GetBuilder, and you can use these approaches to achieve this:
440 443
@@ -448,9 +451,11 @@ GetBuilder<Controller>( @@ -448,9 +451,11 @@ GetBuilder<Controller>(
448 init: Controller(), // use it only first time on each controller 451 init: Controller(), // use it only first time on each controller
449 builder: (_) => Text( 452 builder: (_) => Text(
450 '${Controller.to.counter}', //here 453 '${Controller.to.counter}', //here
451 - )), 454 + )
  455 +),
  456 +```
452 or 457 or
453 - 458 +```dart
454 class Controller extends GetController { 459 class Controller extends GetController {
455 // static Controller get to => Get.find(); // with no static get 460 // static Controller get to => Get.find(); // with no static get
456 [...] 461 [...]
@@ -460,20 +465,21 @@ GetBuilder<Controller>( @@ -460,20 +465,21 @@ GetBuilder<Controller>(
460 init: Controller(), // use it only first time on each controller 465 init: Controller(), // use it only first time on each controller
461 builder: (_) => Text( 466 builder: (_) => Text(
462 '${Get.find<Controller>().counter}', //here 467 '${Get.find<Controller>().counter}', //here
463 - )), 468 + ),
  469 +),
464 ``` 470 ```
465 471
466 - 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: 472 - 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:
467 473
468 ```dart 474 ```dart
469 -  
470 Controller controller = Controller(); 475 Controller controller = Controller();
471 [...] 476 [...]
472 GetBuilder( // you dont need to type on this way 477 GetBuilder( // you dont need to type on this way
473 init: controller, //here 478 init: controller, //here
474 builder: (_) => Text( 479 builder: (_) => Text(
475 '${controller.counter}', // here 480 '${controller.counter}', // here
476 - )), 481 + ),
  482 +),
477 483
478 ``` 484 ```
479 This approach is not recommended, as you will have to manually dispose of your controllers, close your streams manually, and literally give up one of the great benefits of this library, which is intelligent memory control. But if you trust your potential, go ahead! 485 This approach is not recommended, as you will have to manually dispose of your controllers, close your streams manually, and literally give up one of the great benefits of this library, which is intelligent memory control. But if you trust your potential, go ahead!
@@ -485,7 +491,8 @@ GetBuilder<Controller>( @@ -485,7 +491,8 @@ GetBuilder<Controller>(
485 init: Controller(), // use it only first time on each controller 491 init: Controller(), // use it only first time on each controller
486 builder: (_) => Text( 492 builder: (_) => Text(
487 '${Get.find<Controller>().counter}', //here 493 '${Get.find<Controller>().counter}', //here
488 - )), 494 + ),
  495 +),
489 ``` 496 ```
490 And update it this form: 497 And update it this form:
491 ```dart 498 ```dart
@@ -522,24 +529,24 @@ int get sum => count1.value + count2.value; @@ -522,24 +529,24 @@ int get sum => count1.value + count2.value;
522 ``` 529 ```
523 530
524 ```dart 531 ```dart
525 - GetX<Controller>( 532 +GetX<Controller>(
526 builder: (_) { 533 builder: (_) {
527 print("count 1 rebuild"); 534 print("count 1 rebuild");
528 return Text('${_.count1.value}'); 535 return Text('${_.count1.value}');
529 }, 536 },
530 - ),  
531 - GetX<Controller>( 537 +),
  538 +GetX<Controller>(
532 builder: (_) { 539 builder: (_) {
533 print("count 2 rebuild"); 540 print("count 2 rebuild");
534 return Text('${_.count2.value}'); 541 return Text('${_.count2.value}');
535 }, 542 },
536 - ),  
537 - GetX<Controller>( 543 +),
  544 +GetX<Controller>(
538 builder: (_) { 545 builder: (_) {
539 print("count 3 rebuild"); 546 print("count 3 rebuild");
540 return Text('${_.sum}'); 547 return Text('${_.sum}');
541 }, 548 },
542 - ), 549 +),
543 ``` 550 ```
544 551
545 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. 552 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.
@@ -615,8 +622,9 @@ You can access list.length, or list.value.length. Most of the time, both ways wi @@ -615,8 +622,9 @@ You can access list.length, or list.value.length. Most of the time, both ways wi
615 final list = List<User>().obs; 622 final list = List<User>().obs;
616 ``` 623 ```
617 ```dart 624 ```dart
618 -ListView.builder (  
619 -itemCount: list.value.lenght 625 +ListView.builder(
  626 + itemCount: list.value.lenght
  627 +)
620 ``` 628 ```
621 or else create a "get" method for it and abandon "value" for life. example: 629 or else create a "get" method for it and abandon "value" for life. example:
622 630