-[Optional Global Settings and Manual configurations](#optional-global-settings-and-manual-configurations)
-[Breaking changes from 2.0](#breaking-changes-from-20)
-[Why I made this package](#why-i-made-this-package)
-[Why Getx](#why-getx)
# About Get
...
...
@@ -71,7 +70,8 @@ Add "Get" before your materialApp, turning it into GetMaterialApp
voidmain()=>runApp(GetMaterialApp(home:Home()));
```
- 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 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.
- Step 2:
Create your business logic class and place all variables, methods and controllers inside it.
- 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.
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:
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:
```dart
Controllercontroller=Get.put(Controller());// Rather Controller controller = Controller();
```
- Note: If you are using Get's State Manager, pay more attention to the bindings api, which will make easier to connect your view to your controller.
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.
So you can use your controller (or class Bloc) normally
So you can use your controller (or Bloc class) normally
**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
```dart
controller.fetchApi();
...
...
@@ -61,6 +63,77 @@ To remove a instance of Get:
Get.delete<Controller>();
```
## Options
When you use Get.put, lazyPut and putAsync you will have some options that you can change if you want
- On Get.put():
```dart
Get.put<S>(
// mandatory: the class that you want to get to save, like a controller or anything
// note: that "S" means that it can be anything
Sdependency
// optional: this is for when you want multiple classess that are of the same type
// since you normally get a class by using Get.find<Controller>(),
// you need to use tag to tell which instance you need
// must be unique string
Stringtag,
// optional: by default, get will dispose instances after they are not used anymore (example,
// the controller of a view that is closed), but you might need that the instance
// to be kept there throughout the entire app, like an instance of sharedPreferences or something
// so you use this
// defaults to false
boolpermanent=false,
// optional: TODO: make docs about this
// defaults to false
booloverrideAbstract=false,
// optional: TODO: make docs about this
FcBuilderFunc<S>builder,
)
```
- On Get.lazyPut:
```dart
Get.lazyPut<S>(
// mandatory: a method that will be executed when your class is called for the first time
// optional: same as Get.put(), it is used for when you want multiple different instance of a same class
// must be unique
Stringtag,
// optional: same as in Get.put(), used when you need to maintain that instance alive in the entire app
// defaults to false
boolpermanent=false
```
## Bindings
One of the great differentials of this package, perhaps, is the possibility of full integration of the routes, state manager and dependency manager.
...
...
@@ -76,7 +149,9 @@ In addition, the Binding class will allow you to have SmartManager configuration
- Create a class and implements Binding
```dart
classHomeBindingimplementsBindings{
classHomeBindingimplementsBindings{
}
```
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: