Committed by
GitHub
update to 3.1.0
Added extensions to GetUtils and fix typo on GetUtils.isEmail (@stefandevo) Added .gitignore file (@hdeyana) Fix initialRoute on web
Showing
19 changed files
with
511 additions
and
81 deletions
1 | +## [3.1.0] | ||
2 | +- Added extensions to GetUtils and fix typo on GetUtils.isEmail (@stefandevo) | ||
3 | +- Added .gitignore file (@hdeyana) | ||
4 | + | ||
1 | ## [3.0.1] | 5 | ## [3.0.1] |
2 | - Breaking changes on Rx api and GetController and RxController were merged, and now you only have the 'GetxController' | 6 | - Breaking changes on Rx api and GetController and RxController were merged, and now you only have the 'GetxController' |
3 | - Refactor routing system. Now you can add custom transitions and more | 7 | - Refactor routing system. Now you can add custom transitions and more |
@@ -13,7 +17,8 @@ | @@ -13,7 +17,8 @@ | ||
13 | ## [2.14.0] | 17 | ## [2.14.0] |
14 | - Added getPages API. | 18 | - Added getPages API. |
15 | - Deprecated namedPages | 19 | - Deprecated namedPages |
16 | -- Fix default transition | 20 | +- Fix default transition |
21 | +- Added Duration on Get.offAll(@kluverua) | ||
17 | 22 | ||
18 | ## [2.13.1] | 23 | ## [2.13.1] |
19 | - Added sort to ListX | 24 | - Added sort to ListX |
@@ -57,7 +62,7 @@ | @@ -57,7 +62,7 @@ | ||
57 | - Added Permissions: | 62 | - Added Permissions: |
58 | You can now revoke permissions to SmartManagement so that it cannot delete a particular controller. | 63 | You can now revoke permissions to SmartManagement so that it cannot delete a particular controller. |
59 | Add to Get.put (Controller(), permanent: true); to make it indelible. | 64 | Add to Get.put (Controller(), permanent: true); to make it indelible. |
60 | -Get.lazyPut () will not receive this resource. Initially he had it, but we saw in internal tests that it could cause problems with the bindings API. Bindings were created to initialize and delete an instance, if it were allowed to make a controller started with lazyPut permanent, copies of that Controller would be created every time Binding was called. For the safety of users, especially new users who could easily do this, it was decided that this feature will only be present in Get.put. | 65 | +Get.lazyPut() will not receive this resource. Initially he had it, but we saw in internal tests that it could cause problems with the bindings API. Bindings were created to initialize and delete an instance, if it were allowed to make a controller started with lazyPut permanent, copies of that Controller would be created every time Binding was called. For the safety of users, especially new users who could easily do this, it was decided that this feature will only be present in Get.put. |
61 | - Improve: Now a controller's life cycle has no connection with the View life cycle. It is no longer called internally in an "initState", it is now called when the Controller enters memory. This means that now onInit will always be called, regardless of where you started your dependency. | 66 | - Improve: Now a controller's life cycle has no connection with the View life cycle. It is no longer called internally in an "initState", it is now called when the Controller enters memory. This means that now onInit will always be called, regardless of where you started your dependency. |
62 | - removed: this property of the update() method has been permanently removed. | 67 | - removed: this property of the update() method has been permanently removed. |
63 | 68 | ||
@@ -76,20 +81,23 @@ Get.lazyPut () will not receive this resource. Initially he had it, but we saw i | @@ -76,20 +81,23 @@ Get.lazyPut () will not receive this resource. Initially he had it, but we saw i | ||
76 | ## [2.10.0] | 81 | ## [2.10.0] |
77 | - Added SmartManagement, your application's memory is managed intelligently like never before! | 82 | - Added SmartManagement, your application's memory is managed intelligently like never before! |
78 | - Added Obx, a widget that knows when to rebuild a child, without needing any type. | 83 | - Added Obx, a widget that knows when to rebuild a child, without needing any type. |
79 | -- Added MIxinBuilder - If you need to use GetBuilder in conjunction with GetX, use GetxController with this widget, and the changes will occur either using update (this) or changing some reactive variable. Use only if necessary, for better RAM consumption, prefer widgets in that order: | 84 | +- Added MixinBuilder - If you need to use GetBuilder in conjunction with GetX, use GetxController with this widget, and the changes will occur either using update (this) or changing some reactive variable. Use only if necessary, for better RAM consumption, prefer widgets in that order: |
80 | Obx => GetX => GetBuilder => MixinBuilder. | 85 | Obx => GetX => GetBuilder => MixinBuilder. |
81 | Obx is the lightest of all, and MixinBuilder is a mix of the other 3, whenever possible, use the specific widget. | 86 | Obx is the lightest of all, and MixinBuilder is a mix of the other 3, whenever possible, use the specific widget. |
82 | -- Refactor: refactor StateManager of Get. | 87 | +- Refactor: StateManager of Get. |
83 | - Changed: full List API refactor, now value is no longer needed. | 88 | - Changed: full List API refactor, now value is no longer needed. |
84 | - Added Workers: You can hear changes to a variable and trigger custom callbacks. | 89 | - Added Workers: You can hear changes to a variable and trigger custom callbacks. |
85 | - Added Bindings API docs. | 90 | - Added Bindings API docs. |
91 | +- Added Portuguese language to readme(@Nipodemos) | ||
86 | 92 | ||
87 | # [2.7.1] | 93 | # [2.7.1] |
88 | - Improve list to set and get methods | 94 | - Improve list to set and get methods |
89 | 95 | ||
90 | ## [2.7.0] | 96 | ## [2.7.0] |
91 | - Added obx, a simple state interceptor. | 97 | - Added obx, a simple state interceptor. |
92 | -- Improve Bindings, ListX, and fix docs typos | 98 | +- Improve Bindings, ListX, and |
99 | +- fix docs typos e broken code (@ghprod) | ||
100 | + | ||
93 | 101 | ||
94 | ## [2.6.3] | 102 | ## [2.6.3] |
95 | - Flutter currently has a problem on some devices where using showModalBottomSheet() can cause TextFields to be hidden behind the keyboard (https://github.com/flutter/flutter/issues/18564) this issue is closed, even users reporting that the problem still occurs. | 103 | - Flutter currently has a problem on some devices where using showModalBottomSheet() can cause TextFields to be hidden behind the keyboard (https://github.com/flutter/flutter/issues/18564) this issue is closed, even users reporting that the problem still occurs. |
@@ -116,6 +124,7 @@ This feature had been deprecated in previous updates, and was removed in version | @@ -116,6 +124,7 @@ This feature had been deprecated in previous updates, and was removed in version | ||
116 | 124 | ||
117 | ## [2.5.8] | 125 | ## [2.5.8] |
118 | - Added docs | 126 | - Added docs |
127 | +- Added tests(@chimon2000) | ||
119 | 128 | ||
120 | ## [2.5.7] | 129 | ## [2.5.7] |
121 | - Fix Get.generalDialog optionals | 130 | - Fix Get.generalDialog optionals |
@@ -124,6 +133,7 @@ This feature had been deprecated in previous updates, and was removed in version | @@ -124,6 +133,7 @@ This feature had been deprecated in previous updates, and was removed in version | ||
124 | ## [2.5.6] | 133 | ## [2.5.6] |
125 | - GetBuilder refactor to work with lazyPut. | 134 | - GetBuilder refactor to work with lazyPut. |
126 | Now you can list your controllers in advance with Get.lazyPut, and only when it is called for the first time will it be relocated in memory. | 135 | Now you can list your controllers in advance with Get.lazyPut, and only when it is called for the first time will it be relocated in memory. |
136 | +- Fix english typos(@gumbarros) | ||
127 | 137 | ||
128 | ## [2.5.5] | 138 | ## [2.5.5] |
129 | - Fix arguments broken by new methods | 139 | - Fix arguments broken by new methods |
@@ -134,6 +144,7 @@ Now you can list your controllers in advance with Get.lazyPut, and only when it | @@ -134,6 +144,7 @@ Now you can list your controllers in advance with Get.lazyPut, and only when it | ||
134 | ## [2.5.3] | 144 | ## [2.5.3] |
135 | - Fix snackbar padding on iPhone SE 2. | 145 | - Fix snackbar padding on iPhone SE 2. |
136 | - Added themes docs | 146 | - Added themes docs |
147 | +- Added ThemeMode (@RodBr) | ||
137 | 148 | ||
138 | ## [2.5.2] | 149 | ## [2.5.2] |
139 | - Fix: key not found when Get.key is used with no MaterialApp | 150 | - Fix: key not found when Get.key is used with no MaterialApp |
@@ -182,7 +193,7 @@ Now you can list your controllers in advance with Get.lazyPut, and only when it | @@ -182,7 +193,7 @@ Now you can list your controllers in advance with Get.lazyPut, and only when it | ||
182 | - Fix GetRoute not found | 193 | - Fix GetRoute not found |
183 | 194 | ||
184 | ## [2.2.1] | 195 | ## [2.2.1] |
185 | -- Improve lazyPut | 196 | +- Improve lazyPut and fix tag to lazyput(@rochadaniel) |
186 | 197 | ||
187 | ## [2.2.0] | 198 | ## [2.2.0] |
188 | - Added: Ability to choose or delay a widget's state change according to its ID. | 199 | - Added: Ability to choose or delay a widget's state change according to its ID. |
@@ -326,6 +337,7 @@ Now you can list your controllers in advance with Get.lazyPut, and only when it | @@ -326,6 +337,7 @@ Now you can list your controllers in advance with Get.lazyPut, and only when it | ||
326 | 337 | ||
327 | ## [1.10.2] | 338 | ## [1.10.2] |
328 | -Improve snackbar text color | 339 | -Improve snackbar text color |
340 | + -Added background color to snackbar (@claudneysessa) | ||
329 | 341 | ||
330 | ## [1.10.1] | 342 | ## [1.10.1] |
331 | -Backdrop improvement | 343 | -Backdrop improvement |
@@ -14,11 +14,12 @@ | @@ -14,11 +14,12 @@ | ||
14 | <!-- ALL-CONTRIBUTORS-BADGE:END --> | 14 | <!-- ALL-CONTRIBUTORS-BADGE:END --> |
15 | 15 | ||
16 | 16 | ||
17 | -- Get 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. | ||
18 | -- Get is not for everyone, its focus is (performance) on the minimum consumption of resources ([look the benchmarks](https://github.com/jonataslaw/benchmarks)), (productivity) using an easy and pleasant syntax and (organization) allowing the total decoupling of the View from the business logic. | ||
19 | -- Get will save hours of development, and will extract the maximum performance that your application can deliver, being easy for beginners, and accurate for experts. Navigate without context, open dialogs, snackbars or bottomsheets from anywhere in your code, Manage states and inject dependencies in an easy and practical way. Get is secure, stable, up-to-date, and offers a huge range of APIs that are not present on default framework. | 17 | +- 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. |
18 | +- GetX is not for everyone, its focus is (performance) on the minimum consumption of resources ([look the benchmarks](https://github.com/jonataslaw/benchmarks)), (productivity) using an easy and pleasant syntax and (organization) allowing the total decoupling of the View from the business logic. | ||
19 | +- GetX will save hours of development, and will extract the maximum performance that your application can deliver, being easy for beginners, and accurate for experts. Navigate without context, open dialogs, snackbars or bottomsheets from anywhere in your code, Manage states and inject dependencies in an easy and practical way. Get is secure, stable, up-to-date, and offers a huge range of APIs that are not present on default framework. | ||
20 | +- GetX is not a blot. 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 AOT which is incredible, and manages to eliminate unused resources like no other framework does. | ||
20 | 21 | ||
21 | -**Get makes your development productive, but want to make it even more productive? Add the extension [Get extension to VSCode](https://marketplace.visualstudio.com/items?itemName=get-snippets.get-snippets) to your VSCode** | 22 | +**GetX makes your development productive, but want to make it even more productive? Add the extension [GetX extension to VSCode](https://marketplace.visualstudio.com/items?itemName=get-snippets.get-snippets) to your VSCode** |
22 | 23 | ||
23 | 24 | ||
24 | 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. | 25 | 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. |
@@ -28,6 +29,8 @@ Add "Get" before your materialApp, turning it into GetMaterialApp | @@ -28,6 +29,8 @@ Add "Get" before your materialApp, turning it into GetMaterialApp | ||
28 | ```dart | 29 | ```dart |
29 | void main() => runApp(GetMaterialApp(home: Home())); | 30 | void main() => runApp(GetMaterialApp(home: Home())); |
30 | ``` | 31 | ``` |
32 | +- 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. | ||
33 | + | ||
31 | - Step 2: | 34 | - Step 2: |
32 | Create your business logic class and place all variables, methods and controllers inside it. | 35 | Create your business logic class and place all variables, methods and controllers inside it. |
33 | You can make any variable observable using a simple ".obs". | 36 | You can make any variable observable using a simple ".obs". |
@@ -8,7 +8,6 @@ export 'src/snackbar/snack_route.dart'; | @@ -8,7 +8,6 @@ export 'src/snackbar/snack_route.dart'; | ||
8 | export 'src/state/get_state.dart'; | 8 | export 'src/state/get_state.dart'; |
9 | export 'src/state/get_view.dart'; | 9 | export 'src/state/get_view.dart'; |
10 | export 'src/regex/get_utils.dart'; | 10 | export 'src/regex/get_utils.dart'; |
11 | -export 'src/regex/get_utils_extensions.dart'; | ||
12 | export 'src/queue/get_queue.dart'; | 11 | export 'src/queue/get_queue.dart'; |
13 | export 'src/state/mixin_state.dart'; | 12 | export 'src/state/mixin_state.dart'; |
14 | export 'src/rx/rx_interface.dart'; | 13 | export 'src/rx/rx_interface.dart'; |
@@ -24,5 +23,6 @@ export 'src/routes/bindings_interface.dart'; | @@ -24,5 +23,6 @@ export 'src/routes/bindings_interface.dart'; | ||
24 | export 'src/routes/observers/route_observer.dart'; | 23 | export 'src/routes/observers/route_observer.dart'; |
25 | export 'src/routes/transitions_type.dart'; | 24 | export 'src/routes/transitions_type.dart'; |
26 | export 'src/platform/platform.dart'; | 25 | export 'src/platform/platform.dart'; |
27 | -export 'src/extension_instance.dart'; | 26 | +export 'src/instance/extension_instance.dart'; |
28 | export 'src/routes/custom_transition.dart'; | 27 | export 'src/routes/custom_transition.dart'; |
28 | +export 'src/context_extensions/extensions.dart'; |
lib/src/context_extensions/extensions.dart
0 → 100644
1 | +import 'package:flutter/widgets.dart'; | ||
2 | + | ||
3 | +extension MDQ on BuildContext { | ||
4 | + Size get mediaQuerySize => MediaQuery.of(this).size; | ||
5 | + | ||
6 | + double get height => mediaQuerySize.height; | ||
7 | + | ||
8 | + double get width => mediaQuerySize.width; | ||
9 | + | ||
10 | + double heightTransformer({double dividedBy = 1, double reducedBy = 0.0}) { | ||
11 | + return (mediaQuerySize.height - | ||
12 | + ((mediaQuerySize.height / 100) * reducedBy)) / | ||
13 | + dividedBy; | ||
14 | + } | ||
15 | + | ||
16 | + double widthTransformer({double dividedBy = 1, double reducedBy = 0.0}) { | ||
17 | + return (mediaQuerySize.width - ((mediaQuerySize.width / 100) * reducedBy)) / | ||
18 | + dividedBy; | ||
19 | + } | ||
20 | + | ||
21 | + double ratio( | ||
22 | + {double dividedBy = 1, | ||
23 | + double reducedByW = 0.0, | ||
24 | + double reducedByH = 0.0}) { | ||
25 | + return heightTransformer(dividedBy: dividedBy, reducedBy: reducedByH) / | ||
26 | + widthTransformer(dividedBy: dividedBy, reducedBy: reducedByW); | ||
27 | + } | ||
28 | + | ||
29 | + /// similar to MediaQuery.of(this).padding | ||
30 | + EdgeInsets get mediaQueryPadding => MediaQuery.of(this).padding; | ||
31 | + | ||
32 | + /// similar to MediaQuery.of(this).viewPadding | ||
33 | + EdgeInsets get mediaQueryViewPadding => MediaQuery.of(this).viewPadding; | ||
34 | + | ||
35 | + /// similar to MediaQuery.of(this).viewInsets; | ||
36 | + EdgeInsets get mediaQueryViewInsets => MediaQuery.of(this).viewInsets; | ||
37 | + | ||
38 | + /// similar to MediaQuery.of(this).orientation; | ||
39 | + Orientation get orientation => MediaQuery.of(this).orientation; | ||
40 | + | ||
41 | + /// check if device is on landscape mode | ||
42 | + bool get isLandscape => orientation == Orientation.landscape; | ||
43 | + | ||
44 | + /// check if device is on portrait mode | ||
45 | + bool get isPortrait => orientation == Orientation.portrait; | ||
46 | + | ||
47 | + /// similar to MediaQuery.of(this).devicePixelRatio; | ||
48 | + double get devicePixelRatio => MediaQuery.of(this).devicePixelRatio; | ||
49 | + | ||
50 | + /// similar to MediaQuery.of(this).textScaleFactor; | ||
51 | + double get textScaleFactor => MediaQuery.of(this).textScaleFactor; | ||
52 | + | ||
53 | + /// get the shortestSide from screen | ||
54 | + double get mediaQueryShortestSide => mediaQuerySize.shortestSide; | ||
55 | + | ||
56 | + /// True if width be larger than 800 | ||
57 | + bool get showNavbar => (width > 800); | ||
58 | + | ||
59 | + /// True if the shortestSide is smaller than 600p | ||
60 | + bool get isPhone => (mediaQueryShortestSide < 600); | ||
61 | + | ||
62 | + /// True if the shortestSide is largest than 600p | ||
63 | + bool get isSmallTablet => (mediaQueryShortestSide >= 600); | ||
64 | + | ||
65 | + /// True if the shortestSide is largest than 720p | ||
66 | + bool get isLargeTablet => (mediaQueryShortestSide >= 720); | ||
67 | + | ||
68 | + /// True if the current device is Tablet | ||
69 | + bool get isTablet => isSmallTablet || isLargeTablet; | ||
70 | +} |
1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
2 | import 'package:flutter/scheduler.dart'; | 2 | import 'package:flutter/scheduler.dart'; |
3 | import 'package:get/get.dart'; | 3 | import 'package:get/get.dart'; |
4 | -import 'package:get/src/get_instance.dart'; | 4 | +import 'package:get/src/instance/get_instance.dart'; |
5 | import 'package:get/src/get_interface.dart'; | 5 | import 'package:get/src/get_interface.dart'; |
6 | import 'bottomsheet/bottomsheet.dart'; | 6 | import 'bottomsheet/bottomsheet.dart'; |
7 | +import 'instance/get_instance.dart'; | ||
7 | import 'platform/platform.dart'; | 8 | import 'platform/platform.dart'; |
8 | import 'root/parse_route.dart'; | 9 | import 'root/parse_route.dart'; |
9 | import 'root/root_controller.dart'; | 10 | import 'root/root_controller.dart'; |
@@ -22,8 +23,7 @@ import 'snackbar/snack.dart'; | @@ -22,8 +23,7 @@ import 'snackbar/snack.dart'; | ||
22 | class GetImpl implements GetService { | 23 | class GetImpl implements GetService { |
23 | bool defaultPopGesture = GetPlatform.isIOS; | 24 | bool defaultPopGesture = GetPlatform.isIOS; |
24 | bool defaultOpaqueRoute = true; | 25 | bool defaultOpaqueRoute = true; |
25 | - Transition defaultTransition = | ||
26 | - (GetPlatform.isIOS ? Transition.leftToRight : Transition.fadeIn); | 26 | + Transition defaultTransition; |
27 | Duration defaultDurationTransition = Duration(milliseconds: 400); | 27 | Duration defaultDurationTransition = Duration(milliseconds: 400); |
28 | bool defaultGlobalState = true; | 28 | bool defaultGlobalState = true; |
29 | RouteSettings settings; | 29 | RouteSettings settings; |
@@ -631,16 +631,27 @@ class GetImpl implements GetService { | @@ -631,16 +631,27 @@ class GetImpl implements GetService { | ||
631 | } | 631 | } |
632 | } | 632 | } |
633 | 633 | ||
634 | + CustomTransition customTransition; | ||
635 | + | ||
634 | GetMaterialController getxController = GetMaterialController(); | 636 | GetMaterialController getxController = GetMaterialController(); |
635 | 637 | ||
636 | Locale locale; | 638 | Locale locale; |
637 | 639 | ||
638 | void updateLocale(Locale l) { | 640 | void updateLocale(Locale l) { |
639 | locale = l; | 641 | locale = l; |
640 | - getxController.update(); | 642 | + forceAppUpdate(); |
643 | + } | ||
644 | + | ||
645 | + void forceAppUpdate() { | ||
646 | + void rebuild(Element el) { | ||
647 | + el.markNeedsBuild(); | ||
648 | + el.visitChildren(rebuild); | ||
649 | + } | ||
650 | + | ||
651 | + (context as Element).visitChildren(rebuild); | ||
641 | } | 652 | } |
642 | 653 | ||
643 | - Map<String, Map<String, String>> translations; | 654 | + Map<String, Map<String, String>> translations = {}; |
644 | 655 | ||
645 | void addTranslations(Map<String, Map<String, String>> tr) { | 656 | void addTranslations(Map<String, Map<String, String>> tr) { |
646 | translations.addAll(tr); | 657 | translations.addAll(tr); |
lib/src/instance/extension_instance.dart
0 → 100644
1 | +import 'package:get/src/typedefs/typedefs.dart'; | ||
2 | +import '../get_main.dart'; | ||
3 | +import 'get_instance.dart'; | ||
4 | + | ||
5 | +extension Inst on GetImpl { | ||
6 | + void lazyPut<S>(FcBuilderFunc builder, {String tag}) { | ||
7 | + return GetInstance().lazyPut<S>(builder, tag: tag); | ||
8 | + } | ||
9 | + | ||
10 | + Future<S> putAsync<S>(FcBuilderFuncAsync<S> builder, | ||
11 | + {String tag, bool permanent = false}) async => | ||
12 | + GetInstance().putAsync<S>(builder, tag: tag, permanent: permanent); | ||
13 | + | ||
14 | + S find<S>({String tag, FcBuilderFunc<S> instance}) => | ||
15 | + GetInstance().find<S>(tag: tag, instance: instance); | ||
16 | + | ||
17 | + S put<S>(S dependency, | ||
18 | + {String tag, | ||
19 | + bool permanent = false, | ||
20 | + bool overrideAbstract = false, | ||
21 | + FcBuilderFunc<S> builder}) => | ||
22 | + GetInstance().put<S>(dependency, | ||
23 | + tag: tag, | ||
24 | + permanent: permanent, | ||
25 | + overrideAbstract: overrideAbstract, | ||
26 | + builder: builder); | ||
27 | + | ||
28 | + bool reset({bool clearFactory = true, bool clearRouteBindings = true}) => | ||
29 | + GetInstance().reset( | ||
30 | + clearFactory: clearFactory, clearRouteBindings: clearRouteBindings); | ||
31 | + | ||
32 | + /// Delete class instance on [S] and clean memory | ||
33 | + Future<bool> delete<S>({String tag, String key}) async => | ||
34 | + GetInstance().delete<S>(tag: tag, key: key); | ||
35 | + | ||
36 | + bool isRegistred<S>({String tag}) => GetInstance().isRegistred<S>(tag: tag); | ||
37 | +} |
lib/src/instance/get_instance.dart
0 → 100644
1 | +import 'package:get/src/root/smart_management.dart'; | ||
2 | +import 'package:get/src/rx/rx_interface.dart'; | ||
3 | +import 'package:get/src/typedefs/typedefs.dart'; | ||
4 | + | ||
5 | +class GetConfig { | ||
6 | + //////////// INSTANCE MANAGER | ||
7 | + static Map<dynamic, dynamic> _singl = {}; | ||
8 | + static Map<dynamic, FcBuilderFunc> _factory = {}; | ||
9 | + static Map<String, String> routesKey = {}; | ||
10 | + static SmartManagement smartManagement = SmartManagement.full; | ||
11 | + static bool isLogEnable = true; | ||
12 | + static String currentRoute; | ||
13 | +} | ||
14 | + | ||
15 | +class GetInstance { | ||
16 | + factory GetInstance() { | ||
17 | + if (_getInstance == null) _getInstance = GetInstance._(); | ||
18 | + return _getInstance; | ||
19 | + } | ||
20 | + GetInstance._(); | ||
21 | + static GetInstance _getInstance; | ||
22 | + | ||
23 | + void lazyPut<S>(FcBuilderFunc builder, {String tag}) { | ||
24 | + String key = _getKey(S, tag); | ||
25 | + GetConfig._factory.putIfAbsent(key, () => builder); | ||
26 | + } | ||
27 | + | ||
28 | + Future<S> putAsync<S>(FcBuilderFuncAsync<S> builder, | ||
29 | + {String tag, bool permanent = false}) async { | ||
30 | + return put<S>(await builder(), tag: tag, permanent: permanent); | ||
31 | + } | ||
32 | + | ||
33 | + /// Inject class on Get Instance Manager | ||
34 | + S put<S>( | ||
35 | + S dependency, { | ||
36 | + String tag, | ||
37 | + bool permanent = false, | ||
38 | + bool overrideAbstract = false, | ||
39 | + FcBuilderFunc<S> builder, | ||
40 | + }) { | ||
41 | + _insert( | ||
42 | + isSingleton: true, | ||
43 | + replace: overrideAbstract, | ||
44 | + //?? (("$S" == "${dependency.runtimeType}") == false), | ||
45 | + name: tag, | ||
46 | + permanent: permanent, | ||
47 | + builder: builder ?? (() => dependency)); | ||
48 | + return find<S>(tag: tag); | ||
49 | + } | ||
50 | + | ||
51 | + /// Create a new instance from builder class | ||
52 | + /// Example | ||
53 | + /// create(() => Repl()); | ||
54 | + /// Repl a = find(); | ||
55 | + /// Repl b = find(); | ||
56 | + /// print(a==b); (false) | ||
57 | + void create<S>( | ||
58 | + FcBuilderFunc<S> builder, { | ||
59 | + String name, | ||
60 | + }) { | ||
61 | + _insert(isSingleton: false, name: name, builder: builder); | ||
62 | + } | ||
63 | + | ||
64 | + void _insert<S>({ | ||
65 | + bool isSingleton, | ||
66 | + String name, | ||
67 | + bool replace = true, | ||
68 | + bool permanent = false, | ||
69 | + FcBuilderFunc<S> builder, | ||
70 | + }) { | ||
71 | + assert(builder != null); | ||
72 | + String key = _getKey(S, name); | ||
73 | + if (replace) { | ||
74 | + GetConfig._singl[key] = FcBuilder<S>(isSingleton, builder, permanent); | ||
75 | + } else { | ||
76 | + GetConfig._singl.putIfAbsent( | ||
77 | + key, () => FcBuilder<S>(isSingleton, builder, permanent)); | ||
78 | + } | ||
79 | + } | ||
80 | + | ||
81 | + void removeDependencyByRoute(String routeName) async { | ||
82 | + List<String> keysToRemove = []; | ||
83 | + GetConfig.routesKey.forEach((key, value) { | ||
84 | + // if (value == routeName && value != null) { | ||
85 | + if (value == routeName) { | ||
86 | + keysToRemove.add(key); | ||
87 | + } | ||
88 | + }); | ||
89 | + keysToRemove.forEach((element) async { | ||
90 | + await delete(key: element); | ||
91 | + }); | ||
92 | + keysToRemove.forEach((element) { | ||
93 | + GetConfig.routesKey?.remove(element); | ||
94 | + }); | ||
95 | + keysToRemove.clear(); | ||
96 | + } | ||
97 | + | ||
98 | + bool isRouteDependecyNull<S>({String name}) { | ||
99 | + return (GetConfig.routesKey[_getKey(S, name)] == null); | ||
100 | + } | ||
101 | + | ||
102 | + bool isDependencyInit<S>({String name}) { | ||
103 | + String key = _getKey(S, name); | ||
104 | + return GetConfig.routesKey.containsKey(key); | ||
105 | + } | ||
106 | + | ||
107 | + void registerRouteInstance<S>({String tag}) { | ||
108 | + GetConfig.routesKey | ||
109 | + .putIfAbsent(_getKey(S, tag), () => GetConfig.currentRoute); | ||
110 | + } | ||
111 | + | ||
112 | + S findByType<S>(Type type, {String tag}) { | ||
113 | + String key = _getKey(type, tag); | ||
114 | + return GetConfig._singl[key].getSependency() as S; | ||
115 | + } | ||
116 | + | ||
117 | + void initController<S>({String tag}) { | ||
118 | + String key = _getKey(S, tag); | ||
119 | + final i = GetConfig._singl[key].getSependency(); | ||
120 | + | ||
121 | + if (i is DisposableInterface) { | ||
122 | + i.onStart(); | ||
123 | + if (GetConfig.isLogEnable) print('[GET] $key has been initialized'); | ||
124 | + } | ||
125 | + } | ||
126 | + | ||
127 | + /// Find a instance from required class | ||
128 | + S find<S>({String tag, FcBuilderFunc<S> instance}) { | ||
129 | + String key = _getKey(S, tag); | ||
130 | + bool callInit = false; | ||
131 | + if (isRegistred<S>(tag: tag)) { | ||
132 | + if (!isDependencyInit<S>() && | ||
133 | + GetConfig.smartManagement != SmartManagement.onlyBuilder) { | ||
134 | + registerRouteInstance<S>(tag: tag); | ||
135 | + callInit = true; | ||
136 | + } | ||
137 | + | ||
138 | + FcBuilder builder = GetConfig._singl[key] as FcBuilder; | ||
139 | + if (builder == null) { | ||
140 | + if (tag == null) { | ||
141 | + throw "class ${S.toString()} is not register"; | ||
142 | + } else { | ||
143 | + throw "class ${S.toString()} with tag '$tag' is not register"; | ||
144 | + } | ||
145 | + } | ||
146 | + if (callInit) { | ||
147 | + initController<S>(tag: tag); | ||
148 | + } | ||
149 | + | ||
150 | + return GetConfig._singl[key].getSependency() as S; | ||
151 | + } else { | ||
152 | + if (!GetConfig._factory.containsKey(key)) | ||
153 | + throw " $S not found. You need call put<$S>($S()) before"; | ||
154 | + | ||
155 | + if (GetConfig.isLogEnable) | ||
156 | + print('[GET] $S instance was created at that time'); | ||
157 | + S _value = put<S>(GetConfig._factory[key].call() as S); | ||
158 | + | ||
159 | + if (!isDependencyInit<S>() && | ||
160 | + GetConfig.smartManagement != SmartManagement.onlyBuilder) { | ||
161 | + registerRouteInstance<S>(tag: tag); | ||
162 | + callInit = true; | ||
163 | + } | ||
164 | + | ||
165 | + if (GetConfig.smartManagement != SmartManagement.keepFactory) { | ||
166 | + GetConfig._factory.remove(key); | ||
167 | + } | ||
168 | + | ||
169 | + if (callInit) { | ||
170 | + initController<S>(tag: tag); | ||
171 | + } | ||
172 | + return _value; | ||
173 | + } | ||
174 | + } | ||
175 | + | ||
176 | + /// Remove dependency of [S] on dependency abstraction. For concrete class use delete | ||
177 | + void remove<S>({String tag}) { | ||
178 | + String key = _getKey(S, tag); | ||
179 | + FcBuilder builder = GetConfig._singl[key] as FcBuilder; | ||
180 | + final i = builder.dependency; | ||
181 | + | ||
182 | + if (i is DisposableInterface) { | ||
183 | + i.onClose(); | ||
184 | + if (GetConfig.isLogEnable) print('[GET] onClose of $key called'); | ||
185 | + } | ||
186 | + if (builder != null) builder.dependency = null; | ||
187 | + if (GetConfig._singl.containsKey(key)) { | ||
188 | + print('error on remove $key'); | ||
189 | + } else { | ||
190 | + if (GetConfig.isLogEnable) print('[GET] $key removed from memory'); | ||
191 | + } | ||
192 | + } | ||
193 | + | ||
194 | + String _getKey(Type type, String name) { | ||
195 | + return name == null ? type.toString() : type.toString() + name; | ||
196 | + } | ||
197 | + | ||
198 | + bool reset({bool clearFactory = true, bool clearRouteBindings = true}) { | ||
199 | + if (clearFactory) GetConfig._factory.clear(); | ||
200 | + if (clearRouteBindings) GetConfig.routesKey.clear(); | ||
201 | + GetConfig._singl.clear(); | ||
202 | + return true; | ||
203 | + } | ||
204 | + | ||
205 | + /// Delete class instance on [S] and clean memory | ||
206 | + Future<bool> delete<S>({String tag, String key}) async { | ||
207 | + String newKey; | ||
208 | + if (key == null) { | ||
209 | + newKey = _getKey(S, tag); | ||
210 | + } else { | ||
211 | + newKey = key; | ||
212 | + } | ||
213 | + | ||
214 | + if (!GetConfig._singl.containsKey(newKey)) { | ||
215 | + print('Instance $newKey not found'); | ||
216 | + return false; | ||
217 | + } | ||
218 | + | ||
219 | + FcBuilder builder = GetConfig._singl[newKey] as FcBuilder; | ||
220 | + if (builder.permanent) { | ||
221 | + (key == null) | ||
222 | + ? print( | ||
223 | + '[GET] [$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.') | ||
224 | + : print( | ||
225 | + '[GET] [$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.'); | ||
226 | + return false; | ||
227 | + } | ||
228 | + final i = builder.dependency; | ||
229 | + | ||
230 | + if (i is DisposableInterface) { | ||
231 | + await i.onClose(); | ||
232 | + if (GetConfig.isLogEnable) print('[GET] onClose of $newKey called'); | ||
233 | + } | ||
234 | + | ||
235 | + GetConfig._singl.removeWhere((oldkey, value) => (oldkey == newKey)); | ||
236 | + if (GetConfig._singl.containsKey(newKey)) { | ||
237 | + print('[GET] error on remove object $newKey'); | ||
238 | + } else { | ||
239 | + if (GetConfig.isLogEnable) print('[GET] $newKey deleted from memory'); | ||
240 | + } | ||
241 | + // GetConfig.routesKey?.remove(key); | ||
242 | + return true; | ||
243 | + } | ||
244 | + | ||
245 | + /// check if instance is registred | ||
246 | + bool isRegistred<S>({String tag}) => | ||
247 | + GetConfig._singl.containsKey(_getKey(S, tag)); | ||
248 | + | ||
249 | + /// check if instance is prepared | ||
250 | + bool isPrepared<S>({String tag}) => | ||
251 | + GetConfig._factory.containsKey(_getKey(S, tag)); | ||
252 | +} |
@@ -10,19 +10,19 @@ class GetPageMatch { | @@ -10,19 +10,19 @@ class GetPageMatch { | ||
10 | 10 | ||
11 | class ParseRouteTree { | 11 | class ParseRouteTree { |
12 | final List<ParseRouteTreeNode> _nodes = <ParseRouteTreeNode>[]; | 12 | final List<ParseRouteTreeNode> _nodes = <ParseRouteTreeNode>[]; |
13 | - // bool _hasDefaultRoute = false; | 13 | + // bool _hasDefaultRoute = false; |
14 | 14 | ||
15 | void addRoute(GetPage route) { | 15 | void addRoute(GetPage route) { |
16 | String path = route.name; | 16 | String path = route.name; |
17 | 17 | ||
18 | if (path == Navigator.defaultRouteName) { | 18 | if (path == Navigator.defaultRouteName) { |
19 | - //if (_hasDefaultRoute) { | ||
20 | - // throw ("Default route was already defined"); | ||
21 | - //} | 19 | + // if (_hasDefaultRoute) { |
20 | + // throw ("Default route was already defined"); | ||
21 | + // } | ||
22 | var node = ParseRouteTreeNode(path, ParseRouteTreeNodeType.component); | 22 | var node = ParseRouteTreeNode(path, ParseRouteTreeNodeType.component); |
23 | node.routes = [route]; | 23 | node.routes = [route]; |
24 | _nodes.add(node); | 24 | _nodes.add(node); |
25 | - // _hasDefaultRoute = true; | 25 | + // _hasDefaultRoute = true; |
26 | return; | 26 | return; |
27 | } | 27 | } |
28 | if (path.startsWith("/")) { | 28 | if (path.startsWith("/")) { |
1 | import 'package:flutter/foundation.dart'; | 1 | import 'package:flutter/foundation.dart'; |
2 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
3 | import 'package:get/get.dart'; | 3 | import 'package:get/get.dart'; |
4 | +import 'package:get/src/instance/get_instance.dart'; | ||
4 | import 'package:get/src/routes/get_route.dart'; | 5 | import 'package:get/src/routes/get_route.dart'; |
5 | -import '../get_instance.dart'; | ||
6 | -import 'parse_route.dart'; | ||
7 | import 'root_controller.dart'; | 6 | import 'root_controller.dart'; |
8 | import 'smart_management.dart'; | 7 | import 'smart_management.dart'; |
9 | 8 | ||
@@ -24,6 +23,7 @@ class GetMaterialApp extends StatelessWidget { | @@ -24,6 +23,7 @@ class GetMaterialApp extends StatelessWidget { | ||
24 | this.title = '', | 23 | this.title = '', |
25 | this.onGenerateTitle, | 24 | this.onGenerateTitle, |
26 | this.color, | 25 | this.color, |
26 | + this.customTransition, | ||
27 | this.onInit, | 27 | this.onInit, |
28 | this.onDispose, | 28 | this.onDispose, |
29 | this.theme, | 29 | this.theme, |
@@ -77,6 +77,7 @@ class GetMaterialApp extends StatelessWidget { | @@ -77,6 +77,7 @@ class GetMaterialApp extends StatelessWidget { | ||
77 | final ThemeData theme; | 77 | final ThemeData theme; |
78 | final ThemeData darkTheme; | 78 | final ThemeData darkTheme; |
79 | final ThemeMode themeMode; | 79 | final ThemeMode themeMode; |
80 | + final CustomTransition customTransition; | ||
80 | final Color color; | 81 | final Color color; |
81 | final Map<String, Map<String, String>> translationsKeys; | 82 | final Map<String, Map<String, String>> translationsKeys; |
82 | final Translations translations; | 83 | final Translations translations; |
@@ -126,6 +127,27 @@ class GetMaterialApp extends StatelessWidget { | @@ -126,6 +127,27 @@ class GetMaterialApp extends StatelessWidget { | ||
126 | ); | 127 | ); |
127 | } | 128 | } |
128 | 129 | ||
130 | + List<Route<dynamic>> initialRoutesGenerate(String name) { | ||
131 | + final match = Get.routeTree.matchRoute(name); | ||
132 | + Get.parameters = match?.parameters; | ||
133 | + | ||
134 | + return [ | ||
135 | + GetPageRoute( | ||
136 | + page: match.route.page, | ||
137 | + parameter: match.route.parameter, | ||
138 | + settings: RouteSettings(name: name, arguments: null), | ||
139 | + curve: match.route.curve, | ||
140 | + opaque: match.route.opaque, | ||
141 | + binding: match.route.binding, | ||
142 | + bindings: match.route.bindings, | ||
143 | + duration: (transitionDuration ?? match.route.transitionDuration), | ||
144 | + transition: match.route.transition, | ||
145 | + popGesture: match.route.popGesture, | ||
146 | + fullscreenDialog: match.route.fullscreenDialog, | ||
147 | + ) | ||
148 | + ]; | ||
149 | + } | ||
150 | + | ||
129 | @override | 151 | @override |
130 | Widget build(BuildContext context) { | 152 | Widget build(BuildContext context) { |
131 | return GetBuilder<GetMaterialController>( | 153 | return GetBuilder<GetMaterialController>( |
@@ -139,12 +161,13 @@ class GetMaterialApp extends StatelessWidget { | @@ -139,12 +161,13 @@ class GetMaterialApp extends StatelessWidget { | ||
139 | } | 161 | } |
140 | 162 | ||
141 | if (translations != null) { | 163 | if (translations != null) { |
142 | - if (Get.locale == null) Get.translations = translations.keys; | ||
143 | - } | ||
144 | - if (translationsKeys != null) { | 164 | + Get.translations = translations.keys; |
165 | + } else if (translationsKeys != null) { | ||
145 | Get.translations = translationsKeys; | 166 | Get.translations = translationsKeys; |
146 | } | 167 | } |
147 | 168 | ||
169 | + Get.customTransition = customTransition; | ||
170 | + | ||
148 | initialBinding?.dependencies(); | 171 | initialBinding?.dependencies(); |
149 | Get.addPages(getPages); | 172 | Get.addPages(getPages); |
150 | GetConfig.smartManagement = smartManagement; | 173 | GetConfig.smartManagement = smartManagement; |
@@ -171,32 +194,7 @@ class GetMaterialApp extends StatelessWidget { | @@ -171,32 +194,7 @@ class GetMaterialApp extends StatelessWidget { | ||
171 | onGenerateRoute: (getPages != null ? generator : onGenerateRoute), | 194 | onGenerateRoute: (getPages != null ? generator : onGenerateRoute), |
172 | onGenerateInitialRoutes: (getPages == null || home != null) | 195 | onGenerateInitialRoutes: (getPages == null || home != null) |
173 | ? onGenerateInitialRoutes | 196 | ? onGenerateInitialRoutes |
174 | - : (st) { | ||
175 | - GetPageMatch match; | ||
176 | - if (initialRoute == null && getPages != null) { | ||
177 | - match = Get.routeTree?.matchRoute(getPages.first.name); | ||
178 | - } else { | ||
179 | - match = Get.routeTree?.matchRoute(initialRoute); | ||
180 | - } | ||
181 | - Get.parameters = match?.parameters; | ||
182 | - return [ | ||
183 | - GetPageRoute( | ||
184 | - page: match.route.page, | ||
185 | - parameter: match.parameters, | ||
186 | - settings: | ||
187 | - RouteSettings(name: initialRoute, arguments: null), | ||
188 | - curve: match.route.curve, | ||
189 | - opaque: match.route.opaque, | ||
190 | - binding: match.route.binding, | ||
191 | - bindings: match.route.bindings, | ||
192 | - duration: (transitionDuration ?? | ||
193 | - match.route.transitionDuration), | ||
194 | - transition: match.route.transition, | ||
195 | - popGesture: match.route.popGesture, | ||
196 | - fullscreenDialog: match.route.fullscreenDialog, | ||
197 | - ) | ||
198 | - ]; | ||
199 | - }, | 197 | + : initialRoutesGenerate, |
200 | onUnknownRoute: onUnknownRoute, | 198 | onUnknownRoute: onUnknownRoute, |
201 | navigatorObservers: (navigatorObservers == null | 199 | navigatorObservers: (navigatorObservers == null |
202 | ? <NavigatorObserver>[GetObserver(routingCallback)] | 200 | ? <NavigatorObserver>[GetObserver(routingCallback)] |
@@ -235,14 +233,18 @@ abstract class Translations { | @@ -235,14 +233,18 @@ abstract class Translations { | ||
235 | 233 | ||
236 | extension Trans on String { | 234 | extension Trans on String { |
237 | String get tr { | 235 | String get tr { |
236 | + if (Get.locale?.languageCode == null) return this; | ||
238 | if (Get.translations | 237 | if (Get.translations |
239 | .containsKey("${Get.locale.languageCode}_${Get.locale.countryCode}")) { | 238 | .containsKey("${Get.locale.languageCode}_${Get.locale.countryCode}")) { |
240 | return Get.translations[ | 239 | return Get.translations[ |
241 | "${Get.locale.languageCode}_${Get.locale.countryCode}"][this]; | 240 | "${Get.locale.languageCode}_${Get.locale.countryCode}"][this]; |
242 | } else if (Get.translations.containsKey(Get.locale.languageCode)) { | 241 | } else if (Get.translations.containsKey(Get.locale.languageCode)) { |
243 | return Get.translations[Get.locale.languageCode][this]; | 242 | return Get.translations[Get.locale.languageCode][this]; |
243 | + } else if (Get.translations.isNotEmpty) { | ||
244 | + return Get.translations.values.first[this]; | ||
245 | + } else { | ||
246 | + return this; | ||
244 | } | 247 | } |
245 | - return Get.translations.values.first[this]; | ||
246 | } | 248 | } |
247 | 249 | ||
248 | String trArgs([List<String> args]) { | 250 | String trArgs([List<String> args]) { |
@@ -2,8 +2,8 @@ import 'dart:math'; | @@ -2,8 +2,8 @@ import 'dart:math'; | ||
2 | import 'dart:ui' show lerpDouble; | 2 | import 'dart:ui' show lerpDouble; |
3 | import 'package:flutter/gestures.dart'; | 3 | import 'package:flutter/gestures.dart'; |
4 | import 'package:flutter/material.dart'; | 4 | import 'package:flutter/material.dart'; |
5 | -import 'package:get/src/get_instance.dart'; | ||
6 | import 'package:get/src/get_main.dart'; | 5 | import 'package:get/src/get_main.dart'; |
6 | +import 'package:get/src/instance/get_instance.dart'; | ||
7 | import 'package:get/src/platform/platform.dart'; | 7 | import 'package:get/src/platform/platform.dart'; |
8 | import 'bindings_interface.dart'; | 8 | import 'bindings_interface.dart'; |
9 | import 'custom_transition.dart'; | 9 | import 'custom_transition.dart'; |
@@ -73,8 +73,39 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | @@ -73,8 +73,39 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | ||
73 | child: child) | 73 | child: child) |
74 | : child); | 74 | : child); |
75 | } | 75 | } |
76 | + final curvedAnimation = CurvedAnimation( | ||
77 | + parent: animation, | ||
78 | + curve: this.curve ?? Curves.linear, | ||
79 | + ); | ||
80 | + | ||
81 | + if (transition == null) { | ||
82 | + if (Get.customTransition != null) { | ||
83 | + return Get.customTransition.buildTransition( | ||
84 | + context, | ||
85 | + animation, | ||
86 | + secondaryAnimation, | ||
87 | + popGesture ?? Get.defaultPopGesture | ||
88 | + ? _CupertinoBackGestureDetector<T>( | ||
89 | + enabledCallback: () => _isPopGestureEnabled<T>(this), | ||
90 | + onStartPopGesture: () => _startPopGesture<T>(this), | ||
91 | + child: child) | ||
92 | + : child); | ||
93 | + } | ||
94 | + | ||
95 | + if (Get.defaultTransition != null) { | ||
96 | + return TransitionFilter.newTransitionComponent(Get.defaultTransition) | ||
97 | + .buildChildWithTransition( | ||
98 | + context, | ||
99 | + curvedAnimation, | ||
100 | + secondaryAnimation, | ||
101 | + popGesture ?? Get.defaultPopGesture | ||
102 | + ? _CupertinoBackGestureDetector<T>( | ||
103 | + enabledCallback: () => _isPopGestureEnabled<T>(this), | ||
104 | + onStartPopGesture: () => _startPopGesture<T>(this), | ||
105 | + child: child) | ||
106 | + : child); | ||
107 | + } | ||
76 | 108 | ||
77 | - if (transition == Transition.native) { | ||
78 | return Theme.of(context).pageTransitionsTheme.buildTransitions( | 109 | return Theme.of(context).pageTransitionsTheme.buildTransitions( |
79 | this, | 110 | this, |
80 | context, | 111 | context, |
@@ -88,11 +119,6 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | @@ -88,11 +119,6 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | ||
88 | : child); | 119 | : child); |
89 | } | 120 | } |
90 | 121 | ||
91 | - final curvedAnimation = CurvedAnimation( | ||
92 | - parent: animation, | ||
93 | - curve: this.curve ?? Curves.linear, | ||
94 | - ); | ||
95 | - | ||
96 | return TransitionFilter.newTransitionComponent(transition) | 122 | return TransitionFilter.newTransitionComponent(transition) |
97 | .buildChildWithTransition( | 123 | .buildChildWithTransition( |
98 | context, | 124 | context, |
@@ -2,7 +2,6 @@ import 'package:flutter/widgets.dart'; | @@ -2,7 +2,6 @@ import 'package:flutter/widgets.dart'; | ||
2 | import 'package:get/src/routes/bindings_interface.dart'; | 2 | import 'package:get/src/routes/bindings_interface.dart'; |
3 | import 'transitions_type.dart'; | 3 | import 'transitions_type.dart'; |
4 | 4 | ||
5 | - | ||
6 | class GetPage { | 5 | class GetPage { |
7 | final String name; | 6 | final String name; |
8 | final GetPageBuilder page; | 7 | final GetPageBuilder page; |
@@ -43,4 +42,3 @@ class GetPage { | @@ -43,4 +42,3 @@ class GetPage { | ||
43 | assert(maintainState != null), | 42 | assert(maintainState != null), |
44 | assert(fullscreenDialog != null); | 43 | assert(fullscreenDialog != null); |
45 | } | 44 | } |
46 | - |
1 | import 'package:flutter/widgets.dart'; | 1 | import 'package:flutter/widgets.dart'; |
2 | +import 'package:get/src/instance/get_instance.dart'; | ||
2 | import 'package:get/src/root/smart_management.dart'; | 3 | import 'package:get/src/root/smart_management.dart'; |
3 | -import '../../get_instance.dart'; | ||
4 | import '../../get_main.dart'; | 4 | import '../../get_main.dart'; |
5 | 5 | ||
6 | class Routing { | 6 | class Routing { |
1 | import 'package:flutter/widgets.dart'; | 1 | import 'package:flutter/widgets.dart'; |
2 | +import 'package:get/src/instance/get_instance.dart'; | ||
2 | import 'package:get/src/root/smart_management.dart'; | 3 | import 'package:get/src/root/smart_management.dart'; |
3 | -import '../get_instance.dart'; | ||
4 | import 'rx_impl.dart'; | 4 | import 'rx_impl.dart'; |
5 | import 'rx_interface.dart'; | 5 | import 'rx_interface.dart'; |
6 | 6 |
1 | import 'package:flutter/widgets.dart'; | 1 | import 'package:flutter/widgets.dart'; |
2 | -import 'package:get/src/get_instance.dart'; | 2 | +import 'package:get/src/instance/get_instance.dart'; |
3 | import 'package:get/src/root/smart_management.dart'; | 3 | import 'package:get/src/root/smart_management.dart'; |
4 | import 'package:get/src/rx/rx_interface.dart'; | 4 | import 'package:get/src/rx/rx_interface.dart'; |
5 | 5 |
1 | import 'package:flutter/widgets.dart'; | 1 | import 'package:flutter/widgets.dart'; |
2 | -import 'package:get/src/get_instance.dart'; | 2 | +import 'package:get/src/instance/get_instance.dart'; |
3 | 3 | ||
4 | abstract class GetView<T> extends StatelessWidget { | 4 | abstract class GetView<T> extends StatelessWidget { |
5 | const GetView({Key key}) : super(key: key); | 5 | const GetView({Key key}) : super(key: key); |
@@ -134,7 +134,7 @@ packages: | @@ -134,7 +134,7 @@ packages: | ||
134 | name: typed_data | 134 | name: typed_data |
135 | url: "https://pub.dartlang.org" | 135 | url: "https://pub.dartlang.org" |
136 | source: hosted | 136 | source: hosted |
137 | - version: "1.1.6" | 137 | + version: "1.2.0" |
138 | vector_math: | 138 | vector_math: |
139 | dependency: transitive | 139 | dependency: transitive |
140 | description: | 140 | description: |
1 | name: get | 1 | name: get |
2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get. | 2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get. |
3 | -version: 3.0.1 | 3 | +version: 3.1.0 |
4 | homepage: https://github.com/jonataslaw/get | 4 | homepage: https://github.com/jonataslaw/get |
5 | 5 | ||
6 | environment: | 6 | environment: |
@@ -18,14 +18,13 @@ void main() { | @@ -18,14 +18,13 @@ void main() { | ||
18 | }); | 18 | }); |
19 | testWidgets("Get.toNamed smoke test", (tester) async { | 19 | testWidgets("Get.toNamed smoke test", (tester) async { |
20 | await tester.pumpWidget( | 20 | await tester.pumpWidget( |
21 | - Wrapper( | 21 | + GetMaterialApp( |
22 | initialRoute: '/', | 22 | initialRoute: '/', |
23 | - namedRoutes: [ | 23 | + getPages: [ |
24 | GetPage(page: () => FirstScreen(), name: '/'), | 24 | GetPage(page: () => FirstScreen(), name: '/'), |
25 | GetPage(page: () => SecondScreen(), name: '/second'), | 25 | GetPage(page: () => SecondScreen(), name: '/second'), |
26 | GetPage(page: () => ThirdScreen(), name: '/third'), | 26 | GetPage(page: () => ThirdScreen(), name: '/third'), |
27 | ], | 27 | ], |
28 | - child: Container(), | ||
29 | ), | 28 | ), |
30 | ); | 29 | ); |
31 | 30 | ||
@@ -56,15 +55,14 @@ void main() { | @@ -56,15 +55,14 @@ void main() { | ||
56 | 55 | ||
57 | testWidgets("Get.offNamed smoke test", (tester) async { | 56 | testWidgets("Get.offNamed smoke test", (tester) async { |
58 | await tester.pumpWidget( | 57 | await tester.pumpWidget( |
59 | - Wrapper( | 58 | + GetMaterialApp( |
60 | initialRoute: '/', | 59 | initialRoute: '/', |
61 | - namedRoutes: [ | 60 | + getPages: [ |
62 | GetPage(name: '/', page: () => Container()), | 61 | GetPage(name: '/', page: () => Container()), |
63 | GetPage(name: '/first', page: () => FirstScreen()), | 62 | GetPage(name: '/first', page: () => FirstScreen()), |
64 | GetPage(name: '/second', page: () => SecondScreen()), | 63 | GetPage(name: '/second', page: () => SecondScreen()), |
65 | GetPage(name: '/third', page: () => ThirdScreen()), | 64 | GetPage(name: '/third', page: () => ThirdScreen()), |
66 | ], | 65 | ], |
67 | - child: Container(), | ||
68 | ), | 66 | ), |
69 | ); | 67 | ); |
70 | 68 | ||
@@ -107,7 +105,7 @@ void main() { | @@ -107,7 +105,7 @@ void main() { | ||
107 | 105 | ||
108 | testWidgets("Get.offAllNamed smoke test", (tester) async { | 106 | testWidgets("Get.offAllNamed smoke test", (tester) async { |
109 | await tester.pumpWidget( | 107 | await tester.pumpWidget( |
110 | - Wrapper( | 108 | + WrapperNamed( |
111 | initialRoute: '/', | 109 | initialRoute: '/', |
112 | namedRoutes: [ | 110 | namedRoutes: [ |
113 | GetPage(page: () => Container(), name: '/'), | 111 | GetPage(page: () => Container(), name: '/'), |
@@ -115,7 +113,6 @@ void main() { | @@ -115,7 +113,6 @@ void main() { | ||
115 | GetPage(page: () => SecondScreen(), name: '/second'), | 113 | GetPage(page: () => SecondScreen(), name: '/second'), |
116 | GetPage(page: () => ThirdScreen(), name: '/third'), | 114 | GetPage(page: () => ThirdScreen(), name: '/third'), |
117 | ], | 115 | ], |
118 | - child: Container(), | ||
119 | ), | 116 | ), |
120 | ); | 117 | ); |
121 | 118 | ||
@@ -140,7 +137,7 @@ void main() { | @@ -140,7 +137,7 @@ void main() { | ||
140 | 137 | ||
141 | testWidgets("Get.offAndToNamed smoke test", (tester) async { | 138 | testWidgets("Get.offAndToNamed smoke test", (tester) async { |
142 | await tester.pumpWidget( | 139 | await tester.pumpWidget( |
143 | - Wrapper( | 140 | + WrapperNamed( |
144 | initialRoute: '/', | 141 | initialRoute: '/', |
145 | namedRoutes: [ | 142 | namedRoutes: [ |
146 | GetPage(page: () => Container(), name: '/'), | 143 | GetPage(page: () => Container(), name: '/'), |
@@ -148,7 +145,6 @@ void main() { | @@ -148,7 +145,6 @@ void main() { | ||
148 | GetPage(page: () => SecondScreen(), name: '/second'), | 145 | GetPage(page: () => SecondScreen(), name: '/second'), |
149 | GetPage(page: () => ThirdScreen(), name: '/third'), | 146 | GetPage(page: () => ThirdScreen(), name: '/third'), |
150 | ], | 147 | ], |
151 | - child: Container(), | ||
152 | ), | 148 | ), |
153 | ); | 149 | ); |
154 | 150 | ||
@@ -189,7 +185,7 @@ void main() { | @@ -189,7 +185,7 @@ void main() { | ||
189 | 185 | ||
190 | testWidgets("Get.offNamedUntil smoke test", (tester) async { | 186 | testWidgets("Get.offNamedUntil smoke test", (tester) async { |
191 | await tester.pumpWidget( | 187 | await tester.pumpWidget( |
192 | - Wrapper( | 188 | + WrapperNamed( |
193 | initialRoute: '/', | 189 | initialRoute: '/', |
194 | namedRoutes: [ | 190 | namedRoutes: [ |
195 | GetPage(page: () => Container(), name: '/'), | 191 | GetPage(page: () => Container(), name: '/'), |
@@ -197,7 +193,6 @@ void main() { | @@ -197,7 +193,6 @@ void main() { | ||
197 | GetPage(page: () => SecondScreen(), name: '/second'), | 193 | GetPage(page: () => SecondScreen(), name: '/second'), |
198 | GetPage(page: () => ThirdScreen(), name: '/third'), | 194 | GetPage(page: () => ThirdScreen(), name: '/third'), |
199 | ], | 195 | ], |
200 | - child: Container(), | ||
201 | ), | 196 | ), |
202 | ); | 197 | ); |
203 | 198 |
@@ -27,3 +27,27 @@ class Wrapper extends StatelessWidget { | @@ -27,3 +27,27 @@ class Wrapper extends StatelessWidget { | ||
27 | ); | 27 | ); |
28 | } | 28 | } |
29 | } | 29 | } |
30 | + | ||
31 | +class WrapperNamed extends StatelessWidget { | ||
32 | + final Widget child; | ||
33 | + final List<GetPage> namedRoutes; | ||
34 | + final String initialRoute; | ||
35 | + final Transition defaultTransition; | ||
36 | + | ||
37 | + const WrapperNamed({ | ||
38 | + Key key, | ||
39 | + this.child, | ||
40 | + this.namedRoutes, | ||
41 | + this.initialRoute, | ||
42 | + this.defaultTransition, | ||
43 | + }) : super(key: key); | ||
44 | + | ||
45 | + @override | ||
46 | + Widget build(BuildContext context) { | ||
47 | + return GetMaterialApp( | ||
48 | + defaultTransition: defaultTransition, | ||
49 | + initialRoute: initialRoute, | ||
50 | + getPages: namedRoutes, | ||
51 | + ); | ||
52 | + } | ||
53 | +} |
-
Please register or login to post a comment