Showing
1 changed file
with
22 additions
and
2 deletions
@@ -6,12 +6,13 @@ | @@ -6,12 +6,13 @@ | ||
6 | - [Get.putAsync](#getputasync) | 6 | - [Get.putAsync](#getputasync) |
7 | - [Get.create](#getcreate) | 7 | - [Get.create](#getcreate) |
8 | - [Using instantiated methods/classes](#using-instantiated-methodsclasses) | 8 | - [Using instantiated methods/classes](#using-instantiated-methodsclasses) |
9 | + - [Specifying an alternate instance](#specifying-an-alternate-instance) | ||
9 | - [Differences between methods](#differences-between-methods) | 10 | - [Differences between methods](#differences-between-methods) |
10 | - [Bindings](#bindings) | 11 | - [Bindings](#bindings) |
11 | - - [How to use](#how-to-use) | 12 | + - [Bindings class](#bindings-class) |
12 | - [BindingsBuilder](#bindingsbuilder) | 13 | - [BindingsBuilder](#bindingsbuilder) |
13 | - [SmartManagement](#smartmanagement) | 14 | - [SmartManagement](#smartmanagement) |
14 | - - [How to change](#How-to-change) | 15 | + - [How to change](#how-to-change) |
15 | - [SmartManagement.full](#smartmanagementfull) | 16 | - [SmartManagement.full](#smartmanagementfull) |
16 | - [SmartManagement.onlyBuilders](#smartmanagementonlybuilders) | 17 | - [SmartManagement.onlyBuilders](#smartmanagementonlybuilders) |
17 | - [SmartManagement.keepFactory](#smartmanagementkeepfactory) | 18 | - [SmartManagement.keepFactory](#smartmanagementkeepfactory) |
@@ -202,6 +203,25 @@ To remove an instance of Get: | @@ -202,6 +203,25 @@ To remove an instance of Get: | ||
202 | Get.delete<Controller>(); //usually you don't need to do this because GetX already delete unused controllers | 203 | Get.delete<Controller>(); //usually you don't need to do this because GetX already delete unused controllers |
203 | ``` | 204 | ``` |
204 | 205 | ||
206 | +## Specifying an alternate instance | ||
207 | + | ||
208 | +A currently inserted instance can be replaced with a similar or extended class instance by using the `replace` method. This can then be retrieved by using the original class. | ||
209 | + | ||
210 | +```dart | ||
211 | +class ParentClass {} | ||
212 | + | ||
213 | +class ChildClass extends ParentClass { | ||
214 | + bool isChild = true; | ||
215 | +} | ||
216 | + | ||
217 | +Get.put(ParentClass()); | ||
218 | + | ||
219 | +Get.replace<ParentClass, ChildClass>(ChildClass()); | ||
220 | + | ||
221 | +final instance = Get.find<ParentClass>(); | ||
222 | +print(instance is ChildClass); //true | ||
223 | +``` | ||
224 | + | ||
205 | ## Differences between methods | 225 | ## Differences between methods |
206 | 226 | ||
207 | First, let's of the `fenix` of Get.lazyPut and the `permanent` of the other methods. | 227 | First, let's of the `fenix` of Get.lazyPut and the `permanent` of the other methods. |
-
Please register or login to post a comment