Committed by
GitHub
Merge pull request #590 from stefandevo/master
Contribution videos and articles in Readme
Showing
1 changed file
with
81 additions
and
63 deletions
1 |  | 1 |  |
2 | 2 | ||
3 | -*Languages: English (this file), [Brazilian Portuguese](README.pt-br.md), [Spanish](README-es.md),[Polish](README.pl.md).* | 3 | +_Languages: English (this file), [Brazilian Portuguese](README.pt-br.md), [Spanish](README-es.md),[Polish](README.pl.md)._ |
4 | 4 | ||
5 | [](https://pub.dev/packages/get) | 5 | [](https://pub.dev/packages/get) |
6 |  | 6 |  |
@@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
9 | [](https://communityinviter.com/apps/getxworkspace/getx) | 9 | [](https://communityinviter.com/apps/getxworkspace/getx) |
10 | [](https://t.me/joinchat/PhdbJRmsZNpAqSLJL6bH7g) | 10 | [](https://t.me/joinchat/PhdbJRmsZNpAqSLJL6bH7g) |
11 | <a href="https://github.com/Solido/awesome-flutter"> | 11 | <a href="https://github.com/Solido/awesome-flutter"> |
12 | - <img alt="Awesome Flutter" src="https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square" /> | 12 | +<img alt="Awesome Flutter" src="https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square" /> |
13 | </a> | 13 | </a> |
14 | <a href="https://www.buymeacoffee.com/jonataslaw" target="_blank"><img src="https://i.imgur.com/aV6DDA7.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important; box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" > </a> | 14 | <a href="https://www.buymeacoffee.com/jonataslaw" target="_blank"><img src="https://i.imgur.com/aV6DDA7.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important; box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" > </a> |
15 | 15 | ||
@@ -22,28 +22,40 @@ | @@ -22,28 +22,40 @@ | ||
22 | - [State management](#state-management) | 22 | - [State management](#state-management) |
23 | - [Reactive State Manager](#reactive-state-manager) | 23 | - [Reactive State Manager](#reactive-state-manager) |
24 | - [More details about state management](#more-details-about-state-management) | 24 | - [More details about state management](#more-details-about-state-management) |
25 | - - [Video explanation about state management](#video-explanation-about-state-management) | ||
26 | - [Route management](#route-management) | 25 | - [Route management](#route-management) |
27 | - [More details about route management](#more-details-about-route-management) | 26 | - [More details about route management](#more-details-about-route-management) |
28 | - - [Video Explanation](#video-explanation) | ||
29 | - [Dependency management](#dependency-management) | 27 | - [Dependency management](#dependency-management) |
30 | - [More details about dependency management](#more-details-about-dependency-management) | 28 | - [More details about dependency management](#more-details-about-dependency-management) |
31 | -- [How to contribute](#how-to-contribute) | ||
32 | - [Utils](#utils) | 29 | - [Utils](#utils) |
33 | - [Internationalization](#internationalization) | 30 | - [Internationalization](#internationalization) |
31 | + - [Translations](#translations) | ||
32 | + - [Using translations](#using-translations) | ||
33 | + - [Locales](#locales) | ||
34 | + - [Change locale](#change-locale) | ||
35 | + - [System locale](#system-locale) | ||
34 | - [Change Theme](#change-theme) | 36 | - [Change Theme](#change-theme) |
35 | - [Other Advanced APIs](#other-advanced-apis) | 37 | - [Other Advanced APIs](#other-advanced-apis) |
36 | - [Optional Global Settings and Manual configurations](#optional-global-settings-and-manual-configurations) | 38 | - [Optional Global Settings and Manual configurations](#optional-global-settings-and-manual-configurations) |
37 | - - [Video explanation of Other GetX Features](#video-explanation-of-other-getx-features) | 39 | + - [Local State Widgets](#local-state-widgets) |
40 | + - [ValueBuilder](#valuebuilder) | ||
41 | + - [ObxValue](#obxvalue) | ||
42 | + - [Useful tips](#useful-tips) | ||
43 | + - [GetView](#getview) | ||
44 | + - [GetWidget](#getwidget) | ||
45 | + - [GetxService](#getxservice) | ||
38 | - [Breaking changes from 2.0](#breaking-changes-from-20) | 46 | - [Breaking changes from 2.0](#breaking-changes-from-20) |
39 | - [Why Getx?](#why-getx) | 47 | - [Why Getx?](#why-getx) |
40 | - | 48 | +- [Community](#community) |
49 | + - [Community channels](#community-channels) | ||
50 | + - [How to contribute](#how-to-contribute) | ||
51 | + - [Articles and videos](#articles-and-videos) | ||
41 | 52 | ||
42 | # About Get | 53 | # About Get |
43 | 54 | ||
44 | - GetX 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. | 55 | - GetX 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. |
45 | 56 | ||
46 | - GetX has 3 basic principles, this means that this is the priority for all resources in the library | 57 | - GetX has 3 basic principles, this means that this is the priority for all resources in the library |
58 | + | ||
47 | - **PERFORMANCE:** GetX is focused on performance and minimum consumption of resources. Benchmarks are almost always not important in the real world, but if you want, there is a consumption indicator here([benchmarks](https://github.com/jonataslaw/benchmarks)), where GetX does better than other state management approaches, for example. The difference is not large, but it shows our concern not to waste its resources. | 59 | - **PERFORMANCE:** GetX is focused on performance and minimum consumption of resources. Benchmarks are almost always not important in the real world, but if you want, there is a consumption indicator here([benchmarks](https://github.com/jonataslaw/benchmarks)), where GetX does better than other state management approaches, for example. The difference is not large, but it shows our concern not to waste its resources. |
48 | - **PRODUCTIVITY:** GetX uses an easy and pleasant syntax. No matter what you want to do, there is always an easier way with Getx. It will save hours of development, and will extract the maximum performance that your application can deliver | 60 | - **PRODUCTIVITY:** GetX uses an easy and pleasant syntax. No matter what you want to do, there is always an easier way with Getx. It will save hours of development, and will extract the maximum performance that your application can deliver |
49 | - **ORGANIZATION:** GetX allows the total decoupling of the View, presentation logic, business logic, dependency injection, and navigation. You do not need context to navigate between routes, so you are not dependent on the widget tree (visualization) for this. You don't need context to access your controllers / blocks through an inheritedWidget, so you completely decouple your presentation logic and business logic from your visualization layer. You do not need to inject your Controllers/Models/Blocs classes into your widget tree through multiproviders, for this GetX uses its own dependency injection feature, decoupling the DI from its view completely. | 61 | - **ORGANIZATION:** GetX allows the total decoupling of the View, presentation logic, business logic, dependency injection, and navigation. You do not need context to navigate between routes, so you are not dependent on the widget tree (visualization) for this. You don't need context to access your controllers / blocks through an inheritedWidget, so you completely decouple your presentation logic and business logic from your visualization layer. You do not need to inject your Controllers/Models/Blocs classes into your widget tree through multiproviders, for this GetX uses its own dependency injection feature, decoupling the DI from its view completely. |
@@ -51,25 +63,16 @@ | @@ -51,25 +63,16 @@ | ||
51 | BLoC was a starting point for organizing code in Flutter, it separates business logic from visualization. Getx is a natural evolution of this, not only separating the business logic, but the presentation logic. Bonus injection of dependencies and routes are also decoupled, and the data layer is out of it all. You know where everything is, and all of this in an easier way than building a hello world. | 63 | BLoC was a starting point for organizing code in Flutter, it separates business logic from visualization. Getx is a natural evolution of this, not only separating the business logic, but the presentation logic. Bonus injection of dependencies and routes are also decoupled, and the data layer is out of it all. You know where everything is, and all of this in an easier way than building a hello world. |
52 | GetX is the easiest, most practical and scalable way to build high-performance applications with the Flutter SDK, with a large ecosystem around it that works perfectly together, being easy for beginners, and accurate for experts. It is secure, stable, up-to-date, and offers a huge range of APIs build-in that are not present on default Flutter SDK. | 64 | GetX is the easiest, most practical and scalable way to build high-performance applications with the Flutter SDK, with a large ecosystem around it that works perfectly together, being easy for beginners, and accurate for experts. It is secure, stable, up-to-date, and offers a huge range of APIs build-in that are not present on default Flutter SDK. |
53 | 65 | ||
54 | - | ||
55 | - GetX is not a bloated. It has a multitude of features that allow you to start programming without worrying about anything, but each of these features are in separate containers, and are only started after use. If you only use State Management, only State Management will be compiled. If you only use routes, nothing from the state management will be compiled. You can compile the benchmark repository, and you will see that using only Get state management, the application compiled with Get has become smaller than all other applications that have only the state management of other packages, because nothing that is not used will be compiled into your code, and each GetX solution was designed to be extra lightweight. The merit here also comes from Flutter's tree shaking which is incredible, and manages to eliminate unused resources like no other framework does. | 66 | - GetX is not a bloated. It has a multitude of features that allow you to start programming without worrying about anything, but each of these features are in separate containers, and are only started after use. If you only use State Management, only State Management will be compiled. If you only use routes, nothing from the state management will be compiled. You can compile the benchmark repository, and you will see that using only Get state management, the application compiled with Get has become smaller than all other applications that have only the state management of other packages, because nothing that is not used will be compiled into your code, and each GetX solution was designed to be extra lightweight. The merit here also comes from Flutter's tree shaking which is incredible, and manages to eliminate unused resources like no other framework does. |
56 | 67 | ||
57 | - Getx has a huge ecosystem, capable of running with the same code on Android, iOS, Web, Mac, Linux, Windows, and on your server. | 68 | - Getx has a huge ecosystem, capable of running with the same code on Android, iOS, Web, Mac, Linux, Windows, and on your server. |
58 | -It is possible to fully reuse your code made on the frontend on your backend with **[Get Server](https://github.com/jonataslaw/get_server)**. | 69 | + It is possible to fully reuse your code made on the frontend on your backend with **[Get Server](https://github.com/jonataslaw/get_server)**. |
59 | 70 | ||
60 | In addition, the entire development process can be completely automated, both on the server and on the front end with **[Get CLI](https://github.com/jonataslaw/get_cli)**. | 71 | In addition, the entire development process can be completely automated, both on the server and on the front end with **[Get CLI](https://github.com/jonataslaw/get_cli)**. |
61 | 72 | ||
62 | In addition, to further increase your productivity, we have the | 73 | In addition, to further increase your productivity, we have the |
63 | **[extension to VSCode](https://marketplace.visualstudio.com/items?itemName=get-snippets.get-snippets)** and the **[extension to Android Studio/Intellij](https://plugins.jetbrains.com/plugin/14975-getx-snippets)** | 74 | **[extension to VSCode](https://marketplace.visualstudio.com/items?itemName=get-snippets.get-snippets)** and the **[extension to Android Studio/Intellij](https://plugins.jetbrains.com/plugin/14975-getx-snippets)** |
64 | 75 | ||
65 | -**GetX Community channels:** | ||
66 | - | ||
67 | -GetX has a highly active and helpful community. If you have questions, or would like any assistance regarding the use of this framework, please join our community channels, your question will be answered more quickly, and it will be the most suitable place. This repository is exclusive for opening issues, and requesting resources, but feel free to be part of GetX Community. | ||
68 | - | ||
69 | -| **Slack** | **Discord** | **Telegram** | | ||
70 | -| --------- | ------------| ------------ | | ||
71 | -| [](https://communityinviter.com/apps/getxworkspace/getx) | [](https://discord.com/invite/9Hpt99N) | [](https://t.me/joinchat/PhdbJRmsZNpAqSLJL6bH7g) | | ||
72 | - | ||
73 | # Installing | 76 | # Installing |
74 | 77 | ||
75 | Add Get to your pubspec.yaml file: | 78 | Add Get to your pubspec.yaml file: |
@@ -84,12 +87,13 @@ Import get in files that it will be used: | @@ -84,12 +87,13 @@ Import get in files that it will be used: | ||
84 | ```dart | 87 | ```dart |
85 | import 'package:get/get.dart'; | 88 | import 'package:get/get.dart'; |
86 | ``` | 89 | ``` |
90 | + | ||
87 | # Counter App with GetX | 91 | # Counter App with GetX |
88 | 92 | ||
89 | 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. | 93 | 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. |
90 | 94 | ||
91 | - Step 1: | 95 | - Step 1: |
92 | -Add "Get" before your MaterialApp, turning it into GetMaterialApp | 96 | + Add "Get" before your MaterialApp, turning it into GetMaterialApp |
93 | 97 | ||
94 | ```dart | 98 | ```dart |
95 | void main() => runApp(GetMaterialApp(home: Home())); | 99 | void main() => runApp(GetMaterialApp(home: Home())); |
@@ -99,8 +103,8 @@ void main() => runApp(GetMaterialApp(home: Home())); | @@ -99,8 +103,8 @@ void main() => runApp(GetMaterialApp(home: Home())); | ||
99 | - Note²: This step in only necessary if you gonna use route management (`Get.to()`, `Get.back()` and so on). If you not gonna use it then it is not necessary to do step 1 | 103 | - Note²: This step in only necessary if you gonna use route management (`Get.to()`, `Get.back()` and so on). If you not gonna use it then it is not necessary to do step 1 |
100 | 104 | ||
101 | - Step 2: | 105 | - Step 2: |
102 | -Create your business logic class and place all variables, methods and controllers inside it. | ||
103 | -You can make any variable observable using a simple ".obs". | 106 | + Create your business logic class and place all variables, methods and controllers inside it. |
107 | + You can make any variable observable using a simple ".obs". | ||
104 | 108 | ||
105 | ```dart | 109 | ```dart |
106 | class Controller extends GetxController{ | 110 | class Controller extends GetxController{ |
@@ -110,7 +114,7 @@ class Controller extends GetxController{ | @@ -110,7 +114,7 @@ class Controller extends GetxController{ | ||
110 | ``` | 114 | ``` |
111 | 115 | ||
112 | - Step 3: | 116 | - Step 3: |
113 | -Create your View, use StatelessWidget and save some RAM, with Get you may no longer need to use StatefulWidget. | 117 | + Create your View, use StatelessWidget and save some RAM, with Get you may no longer need to use StatefulWidget. |
114 | 118 | ||
115 | ```dart | 119 | ```dart |
116 | class Home extends StatelessWidget { | 120 | class Home extends StatelessWidget { |
@@ -195,20 +199,14 @@ And in the UI, when you want to show that value and update the screen whenever t | @@ -195,20 +199,14 @@ And in the UI, when you want to show that value and update the screen whenever t | ||
195 | Obx(() => Text("${controller.name}")); | 199 | Obx(() => Text("${controller.name}")); |
196 | ``` | 200 | ``` |
197 | 201 | ||
198 | -That's all. It's *that* simple. | 202 | +That's all. It's _that_ simple. |
199 | 203 | ||
200 | ### More details about state management | 204 | ### More details about state management |
201 | 205 | ||
202 | **See an more in-depth explanation of state management [here](./documentation/en_US/state_management.md). There you will see more examples and also the difference between the simple stage manager and the reactive state manager** | 206 | **See an more in-depth explanation of state management [here](./documentation/en_US/state_management.md). There you will see more examples and also the difference between the simple stage manager and the reactive state manager** |
203 | 207 | ||
204 | -### Video explanation about state management | ||
205 | - | ||
206 | - | ||
207 | -Amateur Coder did an awesome video about state management! Link: [Complete GetX State Management](https://www.youtube.com/watch?v=CNpXbeI_slw) | ||
208 | - | ||
209 | You will get a good idea of GetX power. | 208 | You will get a good idea of GetX power. |
210 | 209 | ||
211 | - | ||
212 | ## Route management | 210 | ## Route management |
213 | 211 | ||
214 | If you are going to use routes/snackbars/dialogs/bottomsheets without context, GetX is excellent for you too, just see it: | 212 | If you are going to use routes/snackbars/dialogs/bottomsheets without context, GetX is excellent for you too, just see it: |
@@ -220,7 +218,9 @@ GetMaterialApp( // Before: MaterialApp( | @@ -220,7 +218,9 @@ GetMaterialApp( // Before: MaterialApp( | ||
220 | home: MyHome(), | 218 | home: MyHome(), |
221 | ) | 219 | ) |
222 | ``` | 220 | ``` |
221 | + | ||
223 | Navigate to new screen: | 222 | Navigate to new screen: |
223 | + | ||
224 | ```dart | 224 | ```dart |
225 | 225 | ||
226 | Get.to(NextScreen()); | 226 | Get.to(NextScreen()); |
@@ -250,10 +250,6 @@ Noticed that you didn't had to use context to do any of these things? That's one | @@ -250,10 +250,6 @@ Noticed that you didn't had to use context to do any of these things? That's one | ||
250 | 250 | ||
251 | **Get work with named routes and also offer a lower level control over your routes! There is a in-depth documentation [here](./documentation/en_US/route_management.md)** | 251 | **Get work with named routes and also offer a lower level control over your routes! There is a in-depth documentation [here](./documentation/en_US/route_management.md)** |
252 | 252 | ||
253 | -### Video Explanation | ||
254 | - | ||
255 | -Amateur Coder did an excellent video that cover route management with Get! here is the link: [Complete Getx Navigation](https://www.youtube.com/watch?v=RaqPIoJSTtI) | ||
256 | - | ||
257 | ## Dependency management | 253 | ## Dependency management |
258 | 254 | ||
259 | 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: | 255 | 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: |
@@ -267,7 +263,6 @@ Controller controller = Get.put(Controller()); // Rather Controller controller = | @@ -267,7 +263,6 @@ Controller controller = Get.put(Controller()); // Rather Controller controller = | ||
267 | 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. | 263 | 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. |
268 | So you can use your controller (or class Bloc) normally | 264 | So you can use your controller (or class Bloc) normally |
269 | 265 | ||
270 | - | ||
271 | **Tip:** Get dependency management is decloupled from other parts of the package, so if for example your app is already using a state manager (any one, it doesn't matter), you don't need to rewrite it all, you can use this dependency injection with no problems at all | 266 | **Tip:** Get dependency management is decloupled from other parts of the package, so if for example your app is already using a state manager (any one, it doesn't matter), you don't need to rewrite it all, you can use this dependency injection with no problems at all |
272 | 267 | ||
273 | ```dart | 268 | ```dart |
@@ -291,23 +286,15 @@ Text(controller.textFromApi); | @@ -291,23 +286,15 @@ Text(controller.textFromApi); | ||
291 | 286 | ||
292 | **See a more in-depth explanation of dependency management [here](./documentation/en_US/dependency_management.md)** | 287 | **See a more in-depth explanation of dependency management [here](./documentation/en_US/dependency_management.md)** |
293 | 288 | ||
294 | -# How to contribute | ||
295 | - | ||
296 | -*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.* | ||
297 | - | ||
298 | -- Helping to translate the readme into other languages. | ||
299 | -- Adding documentation to the readme (a lot of Get's functions haven't been documented yet). | ||
300 | -- Write articles or make videos teaching how to use Get (they will be inserted in the Readme and in the future in our Wiki). | ||
301 | -- Offering PRs for code/tests. | ||
302 | -- Including new functions. | ||
303 | - | ||
304 | -Any contribution is welcome! | ||
305 | - | ||
306 | # Utils | 289 | # Utils |
290 | + | ||
307 | ## Internationalization | 291 | ## Internationalization |
292 | + | ||
308 | ### Translations | 293 | ### Translations |
294 | + | ||
309 | Translations are kept as a simple key-value dictionary map. | 295 | Translations are kept as a simple key-value dictionary map. |
310 | To add custom translations, create a class and extend `Translations`. | 296 | To add custom translations, create a class and extend `Translations`. |
297 | + | ||
311 | ```dart | 298 | ```dart |
312 | import 'package:get/get.dart'; | 299 | import 'package:get/get.dart'; |
313 | 300 | ||
@@ -325,12 +312,15 @@ class Messages extends Translations { | @@ -325,12 +312,15 @@ class Messages extends Translations { | ||
325 | ``` | 312 | ``` |
326 | 313 | ||
327 | #### Using translations | 314 | #### Using translations |
315 | + | ||
328 | Just append `.tr` to the specified key and it will be translated, using the current value of `Get.locale` and `Get.fallbackLocale`. | 316 | Just append `.tr` to the specified key and it will be translated, using the current value of `Get.locale` and `Get.fallbackLocale`. |
317 | + | ||
329 | ```dart | 318 | ```dart |
330 | Text('title'.tr); | 319 | Text('title'.tr); |
331 | ``` | 320 | ``` |
332 | 321 | ||
333 | ### Locales | 322 | ### Locales |
323 | + | ||
334 | Pass parameters to `GetMaterialApp` to define the locale and translations. | 324 | Pass parameters to `GetMaterialApp` to define the locale and translations. |
335 | 325 | ||
336 | ```dart | 326 | ```dart |
@@ -343,14 +333,18 @@ return GetMaterialApp( | @@ -343,14 +333,18 @@ return GetMaterialApp( | ||
343 | ``` | 333 | ``` |
344 | 334 | ||
345 | #### Change locale | 335 | #### Change locale |
336 | + | ||
346 | Call `Get.updateLocale(locale)` to update the locale. Translations then automatically use the new locale. | 337 | Call `Get.updateLocale(locale)` to update the locale. Translations then automatically use the new locale. |
338 | + | ||
347 | ```dart | 339 | ```dart |
348 | var locale = Locale('en', 'US'); | 340 | var locale = Locale('en', 'US'); |
349 | Get.updateLocale(locale); | 341 | Get.updateLocale(locale); |
350 | ``` | 342 | ``` |
351 | 343 | ||
352 | #### System locale | 344 | #### System locale |
345 | + | ||
353 | To read the system locale, you could use `window.locale`. | 346 | To read the system locale, you could use `window.locale`. |
347 | + | ||
354 | ```dart | 348 | ```dart |
355 | import 'dart:ui' as ui; | 349 | import 'dart:ui' as ui; |
356 | 350 | ||
@@ -370,6 +364,7 @@ Get.changeTheme(ThemeData.light()); | @@ -370,6 +364,7 @@ Get.changeTheme(ThemeData.light()); | ||
370 | ``` | 364 | ``` |
371 | 365 | ||
372 | If you want to create something like a button that changes the Theme in `onTap`, you can combine two **GetX™** APIs for that: | 366 | If you want to create something like a button that changes the Theme in `onTap`, you can combine two **GetX™** APIs for that: |
367 | + | ||
373 | - The api that checks if the dark `Theme` is being used. | 368 | - The api that checks if the dark `Theme` is being used. |
374 | - And the `Theme` Change API, you can just put this within an `onPressed`: | 369 | - And the `Theme` Change API, you can just put this within an `onPressed`: |
375 | 370 | ||
@@ -379,10 +374,6 @@ Get.changeTheme(Get.isDarkMode? ThemeData.light(): ThemeData.dark()); | @@ -379,10 +374,6 @@ Get.changeTheme(Get.isDarkMode? ThemeData.light(): ThemeData.dark()); | ||
379 | 374 | ||
380 | When `.darkmode` is activated, it will switch to the _light theme_, and when the _light theme_ becomes active, it will change to _dark theme_. | 375 | When `.darkmode` is activated, it will switch to the _light theme_, and when the _light theme_ becomes active, it will change to _dark theme_. |
381 | 376 | ||
382 | -If you want to know in depth how to change the Theme, you can follow this tutorial on Medium which even teaches the persistence of the theme using **GetX™**: | ||
383 | - | ||
384 | -- [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). | ||
385 | - | ||
386 | ## Other Advanced APIs | 377 | ## Other Advanced APIs |
387 | 378 | ||
388 | ```dart | 379 | ```dart |
@@ -587,6 +578,7 @@ Expandable Panel, or maybe modify the current index in `BottomNavigationBar` whi | @@ -587,6 +578,7 @@ Expandable Panel, or maybe modify the current index in `BottomNavigationBar` whi | ||
587 | of the body in a `Scaffold`. | 578 | of the body in a `Scaffold`. |
588 | 579 | ||
589 | #### ValueBuilder | 580 | #### ValueBuilder |
581 | + | ||
590 | A simplification of `StatefulWidget` that works with a `.setState` callback that takes the updated value. | 582 | A simplification of `StatefulWidget` that works with a `.setState` callback that takes the updated value. |
591 | 583 | ||
592 | ```dart | 584 | ```dart |
@@ -603,6 +595,7 @@ ValueBuilder<bool>( | @@ -603,6 +595,7 @@ ValueBuilder<bool>( | ||
603 | ``` | 595 | ``` |
604 | 596 | ||
605 | #### ObxValue | 597 | #### ObxValue |
598 | + | ||
606 | Similar to [`ValueBuilder`](#valuebuilder), but this is the Reactive version, you pass a Rx instance (remember the magical .obs?) and | 599 | Similar to [`ValueBuilder`](#valuebuilder), but this is the Reactive version, you pass a Rx instance (remember the magical .obs?) and |
607 | updates automatically... isn't it awesome? | 600 | updates automatically... isn't it awesome? |
608 | 601 | ||
@@ -617,16 +610,17 @@ ObxValue((data) => Switch( | @@ -617,16 +610,17 @@ ObxValue((data) => Switch( | ||
617 | 610 | ||
618 | ## Useful tips | 611 | ## Useful tips |
619 | 612 | ||
620 | - | ||
621 | `.obs`ervables (also known as _Rx_ Types) have a wide variety of internal methods and operators. | 613 | `.obs`ervables (also known as _Rx_ Types) have a wide variety of internal methods and operators. |
622 | 614 | ||
623 | > Is very common to _believe_ that a property with `.obs` **IS** the actual value... but make no mistake! | 615 | > Is very common to _believe_ that a property with `.obs` **IS** the actual value... but make no mistake! |
624 | -We avoid the Type declaration of the variable, because Dart's compiler is smart enough, and the code | ||
625 | -looks cleaner, but: | 616 | +> We avoid the Type declaration of the variable, because Dart's compiler is smart enough, and the code |
617 | +> looks cleaner, but: | ||
618 | + | ||
626 | ```dart | 619 | ```dart |
627 | var message = 'Hello world'.obs; | 620 | var message = 'Hello world'.obs; |
628 | print( 'Message "$message" has Type ${message.runtimeType}'); | 621 | print( 'Message "$message" has Type ${message.runtimeType}'); |
629 | ``` | 622 | ``` |
623 | + | ||
630 | Even if `message` _prints_ the actual String value, the Type is **RxString**! | 624 | Even if `message` _prints_ the actual String value, the Type is **RxString**! |
631 | 625 | ||
632 | So, you can't do `message.substring( 0, 4 )`. | 626 | So, you can't do `message.substring( 0, 4 )`. |
@@ -767,7 +761,6 @@ If you use, another "not so common" feature of **GetX**: `Get.create()`. | @@ -767,7 +761,6 @@ If you use, another "not so common" feature of **GetX**: `Get.create()`. | ||
767 | That's where `GetWidget` shines... as you can use it, for example, | 761 | That's where `GetWidget` shines... as you can use it, for example, |
768 | to keep a list of Todo items. So, if the widget gets "rebuilt", it will keep the same controller instance. | 762 | to keep a list of Todo items. So, if the widget gets "rebuilt", it will keep the same controller instance. |
769 | 763 | ||
770 | - | ||
771 | #### GetxService | 764 | #### GetxService |
772 | 765 | ||
773 | This class is like a `GetxController`, it shares the same lifecycle ( `onInit()`, `onReady()`, `onClose()`). | 766 | This class is like a `GetxController`, it shares the same lifecycle ( `onInit()`, `onReady()`, `onClose()`). |
@@ -819,16 +812,6 @@ The only way to actually delete a `GetxService`, is with `Get.reset()` which is | @@ -819,16 +812,6 @@ The only way to actually delete a `GetxService`, is with `Get.reset()` which is | ||
819 | "Hot Reboot" of your app. So remember, if you need absolute persistance of a class instance during the | 812 | "Hot Reboot" of your app. So remember, if you need absolute persistance of a class instance during the |
820 | lifetime of your app, use `GetxService`. | 813 | lifetime of your app, use `GetxService`. |
821 | 814 | ||
822 | - | ||
823 | - | ||
824 | - | ||
825 | - | ||
826 | -## Video explanation of Other GetX Features | ||
827 | - | ||
828 | - | ||
829 | -Amateur Coder did an awesome video about utils, storage, bindings and other features! Link: [GetX Other Features](https://youtu.be/ttQtlX_Q0eU) | ||
830 | - | ||
831 | - | ||
832 | # Breaking changes from 2.0 | 815 | # Breaking changes from 2.0 |
833 | 816 | ||
834 | 1- Rx types: | 817 | 1- Rx types: |
@@ -894,3 +877,38 @@ GetMaterialApp( | @@ -894,3 +877,38 @@ GetMaterialApp( | ||
894 | If you need context to find an InheritedWidget, you need it in the view, or pass the context by parameter. I particularly find this solution very ugly, and to work in teams we will always have a dependence on View's business logic. Getx is unorthodox with the standard approach, and while it does not completely ban the use of StatefulWidgets, InitState, etc., it always has a similar approach that can be cleaner. Controllers have life cycles, and when you need to make an APIREST request for example, you don't depend on anything in the view. You can use onInit to initiate the http call, and when the data arrives, the variables will be populated. As GetX is fully reactive (really, and works under streams), once the items are filled, all widgets that use that variable will be automatically updated in the view. This allows people with UI expertise to work only with widgets, and not have to send anything to business logic other than user events (like clicking a button), while people working with business logic will be free to create and test the business logic separately. | 877 | If you need context to find an InheritedWidget, you need it in the view, or pass the context by parameter. I particularly find this solution very ugly, and to work in teams we will always have a dependence on View's business logic. Getx is unorthodox with the standard approach, and while it does not completely ban the use of StatefulWidgets, InitState, etc., it always has a similar approach that can be cleaner. Controllers have life cycles, and when you need to make an APIREST request for example, you don't depend on anything in the view. You can use onInit to initiate the http call, and when the data arrives, the variables will be populated. As GetX is fully reactive (really, and works under streams), once the items are filled, all widgets that use that variable will be automatically updated in the view. This allows people with UI expertise to work only with widgets, and not have to send anything to business logic other than user events (like clicking a button), while people working with business logic will be free to create and test the business logic separately. |
895 | 878 | ||
896 | This library will always be updated and implementing new features. Feel free to offer PRs and contribute to them. | 879 | This library will always be updated and implementing new features. Feel free to offer PRs and contribute to them. |
880 | + | ||
881 | +# Community | ||
882 | + | ||
883 | +## Community channels | ||
884 | + | ||
885 | +GetX has a highly active and helpful community. If you have questions, or would like any assistance regarding the use of this framework, please join our community channels, your question will be answered more quickly, and it will be the most suitable place. This repository is exclusive for opening issues, and requesting resources, but feel free to be part of GetX Community. | ||
886 | + | ||
887 | +| **Slack** | **Discord** | **Telegram** | | ||
888 | +| :-------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------- | | ||
889 | +| [](https://communityinviter.com/apps/getxworkspace/getx) | [](https://discord.com/invite/9Hpt99N) | [](https://t.me/joinchat/PhdbJRmsZNpAqSLJL6bH7g) | | ||
890 | + | ||
891 | +## How to contribute | ||
892 | + | ||
893 | +_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._ | ||
894 | + | ||
895 | +- Helping to translate the readme into other languages. | ||
896 | +- Adding documentation to the readme (a lot of Get's functions haven't been documented yet). | ||
897 | +- Write articles or make videos teaching how to use Get (they will be inserted in the Readme and in the future in our Wiki). | ||
898 | +- Offering PRs for code/tests. | ||
899 | +- Including new functions. | ||
900 | + | ||
901 | +Any contribution is welcome! | ||
902 | + | ||
903 | +## Articles and videos | ||
904 | + | ||
905 | +- [Dynamic Themes in 3 lines using GetX™](https://medium.com/swlh/flutter-dynamic-themes-in-3-lines-c3b375f292e3) - Tutorial by [Rod Brown](https://github.com/RodBr). | ||
906 | +- [Complete GetX™ Navigation](https://www.youtube.com/watch?v=RaqPIoJSTtI) - Route management video by Amateur Coder. | ||
907 | +- [Complete GetX State Management](https://www.youtube.com/watch?v=CNpXbeI_slw) - State management video by Amateur Coder. | ||
908 | +- [GetX™ Other Features](https://youtu.be/ttQtlX_Q0eU) - Utils, storage, bindings and other features video by Amateur Coder. | ||
909 | +- [Firestore User with GetX | Todo App](https://www.youtube.com/watch?v=BiV0DcXgk58) - Video by Amateur Coder. | ||
910 | +- [Firebase Auth with GetX | Todo App](https://www.youtube.com/watch?v=-H-T_BSgfOE) - Video by Amateur Coder. | ||
911 | +- [The Flutter GetX™ Ecosystem ~ State Management](https://medium.com/flutter-community/the-flutter-getx-ecosystem-state-management-881c7235511d) - State management by [Aachman Garg](https://github.com/imaachman). | ||
912 | +- [GetX, the all-in-one Flutter package](https://www.youtube.com/watch?v=IYQgtu9TM74) - A brief tutorial covering State Management and Navigation by Thad Carnevalli. | ||
913 | +- [Build a To-do List App from scratch using Flutter and GetX](https://www.youtube.com/watch?v=EcnqFasHf18) - UI + State Management + Storage video by Thad Carnevalli. | ||
914 | +- [GetX Flutter Firebase Auth Example](https://medium.com/@jeffmcmorris/getx-flutter-firebase-auth-example-b383c1dd1de2) - Article by Jeff McMorris. |
-
Please register or login to post a comment