Udemy
GteX Tutorial -GetX is one of the most popular state management solution in flutter. In addition to state management, GetX provides easy way to manage page routes.
YouTube
Video on YouTube
JSON Viewer Pro
For- GetX
- Navigation
- State Management
- GetX Controller
- Dependency Management
- Translation
- Themes
- GetXService & GetView
- GetWidget
- GetConnect
- GetX Pattern
- Utils
JSON files are hosted by jsonkeeper
Table of Contents
No. | Name | Contents | Screenshots |
---|---|---|---|
1 | Navigation | Get.to() Get.back() Get.off() Get.ofAll() Get.toNamed() Get.offNamed() Get.offAllNamed() |
|
2 | Reactive State Management | final name = ''.obs; final isLogged = false.obs; final count = 0.obs; final balance = 0.0.obs; final number = 0.obs; final items = [].obs; final myMap = {}.obs; Obx(() =>Text('${count.value}')); onPressed: () => increment() |
|
3 | Simple State Management | class Controller extends GetxController {} static Controller get to => Get.find(); update(); GetBuilder() init: Controller(), builder: (controller) => Text('${controller.counter}') |
|
4 | Reactive State Controller | GetX() init: Controller(), builder: (controller) => Text() In 'Controller' class: final count = 0.obs; void increment() { count.value++; } void clearCount() { count.value = 0; } void onInit() { { super.onInit(); ever(count, (_)); everAll([count], (_)); once(count, (_)); debounce(count, (_)); interval(count, (_)) } |
|
5 | Simple State Controller | final controller = Get.put(Controller()); GetBuilder() id: 'count1', builder: (controller) =>Text() In 'Controller' class: int count = 0; void increment() { count++; update(); } void clearCount() { count = 0; update(); } |
|
6 | Dependency Management | Instancing methods Get.put() Get.lazyPut() Get.putAsync() Get.create() Get.delete() Find controller final controller = Get.find< Controller>(); Controller controller = Get.find(); Alternate controller Get.replace() Get.lazyReplace() Binding void dependency(){} Named route > getPages > BindingBuilder() > void Function Named route initialBinding SmartManagement ✰ full onlyBuilder keepFactory |
|
7 | Internationalization | Custom class @override Map< String, Map< String, String>> get keys tr > Text('key'.tr) @key > trParams({'key':'value'}) translations Custom class that extends Translations locale Locale() Get.deviceLocale() Get.updateLocale() fallbackLocale Locale() |
|
8 | Change Theme | void main() async { await GetStorage.init(); runApp(const MyApp()); } Create theme file Config lightTheme & darkTheme Change theme dynamically Get.isDarkMode > bool Get.changeThemeMode() Get.changeTheme() Store them in local storage GetStorage() > read() & write() |
|
9 | GetX Service & GetView | void main() async { WidgetsFlutterBinding.ensureInitialized(); await initServices(); runApp(const MyApp()); } GetView< SettingsService> late SharedPreferences _prefs; final counter = 0.obs; |
Life Cycle of GetX Controller
Dependency Management using GetX
Internationalization/Translations using GetX
For language code: http://lingoes.net/en/translator/langcode.htm
For language code: https://www.science.co.il/language/Codes.php