- Note: this does not modify the MaterialApp of the Flutter, GetMaterialApp is not a modified MaterialApp, it is just a pre-configured Widget, which has the default MaterialApp as a child. You can configure this manually, but it is definitely not necessary. GetMaterialApp will create routes, inject them, inject translations, inject everything you need for route navigation. If you use Get only for state management or dependency management, it is not necessary to use GetMaterialApp. GetMaterialApp is necessary for routes, snackbars, internationalization, bottomSheets, dialogs, and high-level apis related to routes and absence of context.
- 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
- Note²: This step is only necessary if you gonna use route management (`Get.to()`, `Get.back()` and so on). If you not gonna use it then it is not necessary to do step 1
- Step 2:
Create your business logic class and place all variables, methods and controllers inside it.
@@ -282,6 +282,7 @@ As the view has only widgets, you can use a view for android, and another for iO
However, some examples like internationalization, Snackbars without context, validators, responsiveness and other Getx resources, were not explored (and it would not even be possible to explore all resources in such a simple example), so below is an example not very complete, but trying demonstrate how to use internationalization, reactive custom classes, reactive lists, snackbars contextless, workers etc.
```dart
import'dart:ui';
import'package:flutter/material.dart';
import'package:get/get.dart';
...
...
@@ -397,29 +398,27 @@ class Second extends GetView<ControllerX> {
child:Column(
mainAxisAlignment:MainAxisAlignment.center,
children:[
GetX<ControllerX>(
// Using bindings you don't need of init: method
// Using Getx you can take controller instance of "builder: (_)"
@@ -519,6 +521,9 @@ extension GetNavigation on GetInterface {
Using a widget function instead of a widget fully guarantees that the widget and its controllers will be removed from memory when they are no longer used.
''');
return()=>page;
}elseif(pageisString){
throw'''Unexpected String,
use toNamed() instead''';
}else{
throw'''Unexpected format,
you can only use widgets and widget functions here''';