Showing
21 changed files
with
153 additions
and
120 deletions
@@ -47,13 +47,20 @@ | @@ -47,13 +47,20 @@ | ||
47 | # About Get | 47 | # About Get |
48 | 48 | ||
49 | - 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. | 49 | - 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. |
50 | -- 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. | ||
51 | -- 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. | ||
52 | -- Navigate without `context`, open `dialogs`, `snackbars` or `bottomsheets` from anywhere in your code, Manage states and inject dependencies in an easy and practical way. | ||
53 | -- Get is secure, stable, up-to-date, and offers a huge range of APIs that are not present on default framework. | ||
54 | -- GetX is not `bloated`. 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. | ||
55 | 50 | ||
56 | -**GetX makes your development productive, but want to make it even more productive? Add the extension [GetX extension](https://marketplace.visualstudio.com/items?itemName=get-snippets.get-snippets) to your VSCode**. Not available in other IDEs for now. | 51 | + |
52 | +- GetX has 3 basic principles, this means that this is the priority for all resources in the library | ||
53 | +**PERFORMANCE:** GetX is focused on performance and minimum consumption of resources. Benchmarks are almost always not important in the real world, but if you want, there is a consumption indicator here([benchmarks](https://github.com/jonataslaw/benchmarks)), where GetX does better than other state management approaches, for example. The difference is not large, but it shows our concern not to waste its resources. | ||
54 | +**PRODUCTIVITY:** GetX uses an easy and pleasant syntax. | ||
55 | +**ORGANIZATION:** GetX allows total decoupling of the View from the business logic. | ||
56 | + | ||
57 | + | ||
58 | +- 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. | ||
59 | + | ||
60 | + | ||
61 | +- GetX is not a bloated. 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 tree shaking which is incredible, and manages to eliminate unused resources like no other framework does. | ||
62 | + | ||
63 | +**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** | ||
57 | 64 | ||
58 | # Installing | 65 | # Installing |
59 | 66 |
@@ -105,7 +105,7 @@ packages: | @@ -105,7 +105,7 @@ packages: | ||
105 | name: characters | 105 | name: characters |
106 | url: "https://pub.dartlang.org" | 106 | url: "https://pub.dartlang.org" |
107 | source: hosted | 107 | source: hosted |
108 | - version: "1.0.0" | 108 | + version: "1.1.0-nullsafety" |
109 | charcode: | 109 | charcode: |
110 | dependency: transitive | 110 | dependency: transitive |
111 | description: | 111 | description: |
@@ -140,7 +140,7 @@ packages: | @@ -140,7 +140,7 @@ packages: | ||
140 | name: collection | 140 | name: collection |
141 | url: "https://pub.dartlang.org" | 141 | url: "https://pub.dartlang.org" |
142 | source: hosted | 142 | source: hosted |
143 | - version: "1.14.13" | 143 | + version: "1.15.0-nullsafety" |
144 | convert: | 144 | convert: |
145 | dependency: transitive | 145 | dependency: transitive |
146 | description: | 146 | description: |
@@ -311,7 +311,7 @@ packages: | @@ -311,7 +311,7 @@ packages: | ||
311 | name: meta | 311 | name: meta |
312 | url: "https://pub.dartlang.org" | 312 | url: "https://pub.dartlang.org" |
313 | source: hosted | 313 | source: hosted |
314 | - version: "1.1.8" | 314 | + version: "1.3.0-nullsafety" |
315 | mime: | 315 | mime: |
316 | dependency: transitive | 316 | dependency: transitive |
317 | description: | 317 | description: |
@@ -512,7 +512,7 @@ packages: | @@ -512,7 +512,7 @@ packages: | ||
512 | name: typed_data | 512 | name: typed_data |
513 | url: "https://pub.dartlang.org" | 513 | url: "https://pub.dartlang.org" |
514 | source: hosted | 514 | source: hosted |
515 | - version: "1.2.0" | 515 | + version: "1.3.0-nullsafety" |
516 | uuid: | 516 | uuid: |
517 | dependency: "direct main" | 517 | dependency: "direct main" |
518 | description: | 518 | description: |
@@ -526,7 +526,7 @@ packages: | @@ -526,7 +526,7 @@ packages: | ||
526 | name: vector_math | 526 | name: vector_math |
527 | url: "https://pub.dartlang.org" | 527 | url: "https://pub.dartlang.org" |
528 | source: hosted | 528 | source: hosted |
529 | - version: "2.0.8" | 529 | + version: "2.1.0-nullsafety" |
530 | watcher: | 530 | watcher: |
531 | dependency: transitive | 531 | dependency: transitive |
532 | description: | 532 | description: |
@@ -549,5 +549,5 @@ packages: | @@ -549,5 +549,5 @@ packages: | ||
549 | source: hosted | 549 | source: hosted |
550 | version: "2.2.1" | 550 | version: "2.2.1" |
551 | sdks: | 551 | sdks: |
552 | - dart: ">=2.9.0-14.0.dev <3.0.0" | 552 | + dart: ">=2.9.0-18.0 <2.9.0" |
553 | flutter: ">=1.16.0" | 553 | flutter: ">=1.16.0" |
1 | +import 'package:dio/dio.dart'; | ||
1 | import 'package:get/get.dart'; | 2 | import 'package:get/get.dart'; |
2 | -import 'package:get_state/home/controllers/home_controller.dart'; | ||
3 | -import 'package:get_state/home/data/home_provider.dart'; | ||
4 | -import 'package:get_state/home/data/home_repository.dart'; | 3 | +import '../controllers/home_controller.dart'; |
4 | +import '../data/home_provider.dart'; | ||
5 | +import '../data/home_repository.dart'; | ||
5 | 6 | ||
6 | class HomeBinding extends Bindings { | 7 | class HomeBinding extends Bindings { |
7 | @override | 8 | @override |
8 | void dependencies() { | 9 | void dependencies() { |
9 | Get.lazyPut<HomeController>(() { | 10 | Get.lazyPut<HomeController>(() { |
10 | - final homeProvider = HomeProvider(); | ||
11 | - final homeRepository = HomeRepository(homeProvider); | ||
12 | - return HomeController(homeRepository); | 11 | + Get.put(Dio()); |
12 | + Get.put(HomeProvider(dio: Get.find())); | ||
13 | + Get.put(HomeRepository(homeProvider: Get.find())); | ||
14 | + return HomeController(homeRepository: Get.find()); | ||
13 | }); | 15 | }); |
14 | } | 16 | } |
15 | } | 17 | } |
1 | import 'package:get/get.dart'; | 1 | import 'package:get/get.dart'; |
2 | -import 'package:get_state/home/data/home_model.dart'; | ||
3 | -import 'package:get_state/home/data/home_repository.dart'; | 2 | +import '../data/home_model.dart'; |
3 | +import '../data/home_repository.dart'; | ||
4 | 4 | ||
5 | class HomeController extends GetxController { | 5 | class HomeController extends GetxController { |
6 | - HomeController(this.homeRepository); | 6 | + HomeController({this.homeRepository}); |
7 | final HomeRepository homeRepository; | 7 | final HomeRepository homeRepository; |
8 | 8 | ||
9 | Rx<ApiModel> data = Rx<ApiModel>(); | 9 | Rx<ApiModel> data = Rx<ApiModel>(); |
1 | import 'package:dio/dio.dart'; | 1 | import 'package:dio/dio.dart'; |
2 | -import 'package:get_state/home/data/home_model.dart'; | 2 | +import 'package:flutter/foundation.dart'; |
3 | +import 'home_model.dart'; | ||
3 | 4 | ||
4 | -class HomeProvider { | ||
5 | - Future<ApiModel> fetchData() async { | 5 | +abstract class IHomeProvider { |
6 | + Future<ApiModel> get(); | ||
7 | + Future<ApiModel> post(Map<String, dynamic> data); | ||
8 | + Future<ApiModel> put(Map<String, dynamic> data); | ||
9 | + Future<ApiModel> delete(int id); | ||
10 | +} | ||
11 | + | ||
12 | +class HomeProvider implements IHomeProvider { | ||
13 | + final Dio dio; | ||
14 | + | ||
15 | + HomeProvider({@required this.dio}); | ||
16 | + | ||
17 | + Future<ApiModel> get() async { | ||
6 | try { | 18 | try { |
7 | - final response = await Dio().get("https://api.covid19api.com/summary"); | 19 | + final response = await dio.get("https://api.covid19api.com/summary"); |
8 | return ApiModel.fromJson(response.data); | 20 | return ApiModel.fromJson(response.data); |
9 | } catch (e) { | 21 | } catch (e) { |
10 | print(e.toString()); | 22 | print(e.toString()); |
11 | return null; | 23 | return null; |
12 | } | 24 | } |
13 | } | 25 | } |
26 | + | ||
27 | + @override | ||
28 | + Future<ApiModel> post(Map<String, dynamic> data) { | ||
29 | + throw UnimplementedError(); | ||
30 | + } | ||
31 | + | ||
32 | + @override | ||
33 | + Future<ApiModel> put(Map<String, dynamic> data) { | ||
34 | + throw UnimplementedError(); | ||
35 | + } | ||
36 | + | ||
37 | + @override | ||
38 | + Future<ApiModel> delete(int id) { | ||
39 | + throw UnimplementedError(); | ||
40 | + } | ||
14 | } | 41 | } |
1 | -import 'package:get_state/home/data/home_provider.dart'; | ||
2 | -import 'package:get_state/home/data/home_model.dart'; | 1 | +import 'home_model.dart'; |
2 | +import 'home_provider.dart'; | ||
3 | 3 | ||
4 | class HomeRepository { | 4 | class HomeRepository { |
5 | - HomeRepository(this.homeProvider); | 5 | + HomeRepository({this.homeProvider}); |
6 | final HomeProvider homeProvider; | 6 | final HomeProvider homeProvider; |
7 | 7 | ||
8 | Future<ApiModel> getData() async { | 8 | Future<ApiModel> getData() async { |
9 | - return homeProvider.fetchData(); | 9 | + return homeProvider.get(); |
10 | } | 10 | } |
11 | } | 11 | } |
@@ -7,7 +7,7 @@ packages: | @@ -7,7 +7,7 @@ packages: | ||
7 | name: async | 7 | name: async |
8 | url: "https://pub.dartlang.org" | 8 | url: "https://pub.dartlang.org" |
9 | source: hosted | 9 | source: hosted |
10 | - version: "2.4.1" | 10 | + version: "2.4.2" |
11 | boolean_selector: | 11 | boolean_selector: |
12 | dependency: transitive | 12 | dependency: transitive |
13 | description: | 13 | description: |
@@ -21,7 +21,7 @@ packages: | @@ -21,7 +21,7 @@ packages: | ||
21 | name: characters | 21 | name: characters |
22 | url: "https://pub.dartlang.org" | 22 | url: "https://pub.dartlang.org" |
23 | source: hosted | 23 | source: hosted |
24 | - version: "1.0.0" | 24 | + version: "1.1.0-nullsafety" |
25 | charcode: | 25 | charcode: |
26 | dependency: transitive | 26 | dependency: transitive |
27 | description: | 27 | description: |
@@ -42,14 +42,14 @@ packages: | @@ -42,14 +42,14 @@ packages: | ||
42 | name: collection | 42 | name: collection |
43 | url: "https://pub.dartlang.org" | 43 | url: "https://pub.dartlang.org" |
44 | source: hosted | 44 | source: hosted |
45 | - version: "1.14.13" | 45 | + version: "1.15.0-nullsafety" |
46 | dio: | 46 | dio: |
47 | dependency: "direct main" | 47 | dependency: "direct main" |
48 | description: | 48 | description: |
49 | name: dio | 49 | name: dio |
50 | url: "https://pub.dartlang.org" | 50 | url: "https://pub.dartlang.org" |
51 | source: hosted | 51 | source: hosted |
52 | - version: "3.0.9" | 52 | + version: "3.0.10" |
53 | fake_async: | 53 | fake_async: |
54 | dependency: transitive | 54 | dependency: transitive |
55 | description: | 55 | description: |
@@ -73,7 +73,7 @@ packages: | @@ -73,7 +73,7 @@ packages: | ||
73 | name: get | 73 | name: get |
74 | url: "https://pub.dartlang.org" | 74 | url: "https://pub.dartlang.org" |
75 | source: hosted | 75 | source: hosted |
76 | - version: "3.2.2" | 76 | + version: "3.4.3" |
77 | http_parser: | 77 | http_parser: |
78 | dependency: transitive | 78 | dependency: transitive |
79 | description: | 79 | description: |
@@ -94,7 +94,7 @@ packages: | @@ -94,7 +94,7 @@ packages: | ||
94 | name: meta | 94 | name: meta |
95 | url: "https://pub.dartlang.org" | 95 | url: "https://pub.dartlang.org" |
96 | source: hosted | 96 | source: hosted |
97 | - version: "1.1.8" | 97 | + version: "1.3.0-nullsafety" |
98 | path: | 98 | path: |
99 | dependency: transitive | 99 | dependency: transitive |
100 | description: | 100 | description: |
@@ -120,7 +120,7 @@ packages: | @@ -120,7 +120,7 @@ packages: | ||
120 | name: stack_trace | 120 | name: stack_trace |
121 | url: "https://pub.dartlang.org" | 121 | url: "https://pub.dartlang.org" |
122 | source: hosted | 122 | source: hosted |
123 | - version: "1.9.3" | 123 | + version: "1.9.5" |
124 | stream_channel: | 124 | stream_channel: |
125 | dependency: transitive | 125 | dependency: transitive |
126 | description: | 126 | description: |
@@ -155,13 +155,13 @@ packages: | @@ -155,13 +155,13 @@ packages: | ||
155 | name: typed_data | 155 | name: typed_data |
156 | url: "https://pub.dartlang.org" | 156 | url: "https://pub.dartlang.org" |
157 | source: hosted | 157 | source: hosted |
158 | - version: "1.2.0" | 158 | + version: "1.3.0-nullsafety" |
159 | vector_math: | 159 | vector_math: |
160 | dependency: transitive | 160 | dependency: transitive |
161 | description: | 161 | description: |
162 | name: vector_math | 162 | name: vector_math |
163 | url: "https://pub.dartlang.org" | 163 | url: "https://pub.dartlang.org" |
164 | source: hosted | 164 | source: hosted |
165 | - version: "2.0.8" | 165 | + version: "2.1.0-nullsafety" |
166 | sdks: | 166 | sdks: |
167 | - dart: ">=2.9.0-14.0.dev <3.0.0" | 167 | + dart: ">=2.9.0-18.0 <2.9.0" |
@@ -7,7 +7,7 @@ export 'src/navigation/root/root_widget.dart'; | @@ -7,7 +7,7 @@ export 'src/navigation/root/root_widget.dart'; | ||
7 | export 'src/navigation/snackbar/snack_route.dart'; | 7 | export 'src/navigation/snackbar/snack_route.dart'; |
8 | export 'src/navigation/bottomsheet/bottomsheet.dart'; | 8 | export 'src/navigation/bottomsheet/bottomsheet.dart'; |
9 | export 'src/navigation/snackbar/snack.dart'; | 9 | export 'src/navigation/snackbar/snack.dart'; |
10 | -export 'src/get_main.dart'; | 10 | +export 'src/core/get_main.dart'; |
11 | export 'src/navigation/routes/default_route.dart'; | 11 | export 'src/navigation/routes/default_route.dart'; |
12 | export 'src/navigation/root/smart_management.dart'; | 12 | export 'src/navigation/root/smart_management.dart'; |
13 | export 'src/navigation/extension_navigation.dart'; | 13 | export 'src/navigation/extension_navigation.dart'; |
1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
2 | -import 'navigation/root/parse_route.dart'; | ||
3 | -import 'navigation/root/root_controller.dart'; | ||
4 | -import 'navigation/routes/custom_transition.dart'; | ||
5 | -import 'navigation/routes/observers/route_observer.dart'; | ||
6 | -import 'navigation/routes/transitions_type.dart'; | ||
7 | -import '../utils.dart'; | 2 | +import '../navigation/root/parse_route.dart'; |
3 | +import '../navigation/root/root_controller.dart'; | ||
4 | +import '../navigation/routes/custom_transition.dart'; | ||
5 | +import '../navigation/routes/observers/route_observer.dart'; | ||
6 | +import '../navigation/routes/transitions_type.dart'; | ||
7 | +import '../../utils.dart'; | ||
8 | 8 | ||
9 | ///Use Get.to instead of Navigator.push, Get.off instead of Navigator.pushReplacement, | 9 | ///Use Get.to instead of Navigator.push, Get.off instead of Navigator.pushReplacement, |
10 | ///Get.offAll instead of Navigator.pushAndRemoveUntil. For named routes just add "named" | 10 | ///Get.offAll instead of Navigator.pushAndRemoveUntil. For named routes just add "named" |
1 | -import 'package:get/src/get_interface.dart'; | 1 | +import 'package:get/src/core/get_interface.dart'; |
2 | 2 | ||
3 | ///Use to instead of Navigator.push, off instead of Navigator.pushReplacement, | 3 | ///Use to instead of Navigator.push, off instead of Navigator.pushReplacement, |
4 | ///offAll instead of Navigator.pushAndRemoveUntil. For named routes just add "named" | 4 | ///offAll instead of Navigator.pushAndRemoveUntil. For named routes just add "named" |
@@ -2,10 +2,6 @@ import 'package:get/src/navigation/root/smart_management.dart'; | @@ -2,10 +2,6 @@ import 'package:get/src/navigation/root/smart_management.dart'; | ||
2 | import 'package:get/src/state_manager/rx/rx_interface.dart'; | 2 | import 'package:get/src/state_manager/rx/rx_interface.dart'; |
3 | 3 | ||
4 | class GetConfig { | 4 | class GetConfig { |
5 | - //////////// INSTANCE MANAGER | ||
6 | - static Map<dynamic, dynamic> _singl = {}; | ||
7 | - static Map<dynamic, Lazy> _factory = {}; | ||
8 | - static Map<String, String> routesKey = {}; | ||
9 | static SmartManagement smartManagement = SmartManagement.full; | 5 | static SmartManagement smartManagement = SmartManagement.full; |
10 | static bool isLogEnable = true; | 6 | static bool isLogEnable = true; |
11 | static String currentRoute; | 7 | static String currentRoute; |
@@ -25,10 +21,14 @@ class GetInstance { | @@ -25,10 +21,14 @@ class GetInstance { | ||
25 | const GetInstance._(); | 21 | const GetInstance._(); |
26 | static GetInstance _getInstance; | 22 | static GetInstance _getInstance; |
27 | 23 | ||
24 | + static Map<dynamic, dynamic> _singl = {}; | ||
25 | + static Map<dynamic, Lazy> _factory = {}; | ||
26 | + static Map<String, String> _routesKey = {}; | ||
27 | + | ||
28 | void lazyPut<S>(FcBuilderFunc builder, {String tag, bool fenix = false}) { | 28 | void lazyPut<S>(FcBuilderFunc builder, {String tag, bool fenix = false}) { |
29 | String key = _getKey(S, tag); | 29 | String key = _getKey(S, tag); |
30 | 30 | ||
31 | - GetConfig._factory.putIfAbsent(key, () => Lazy(builder, fenix)); | 31 | + _factory.putIfAbsent(key, () => Lazy(builder, fenix)); |
32 | } | 32 | } |
33 | 33 | ||
34 | Future<S> putAsync<S>(FcBuilderFuncAsync<S> builder, | 34 | Future<S> putAsync<S>(FcBuilderFuncAsync<S> builder, |
@@ -75,14 +75,13 @@ class GetInstance { | @@ -75,14 +75,13 @@ class GetInstance { | ||
75 | assert(builder != null); | 75 | assert(builder != null); |
76 | String key = _getKey(S, name); | 76 | String key = _getKey(S, name); |
77 | 77 | ||
78 | - GetConfig._singl.putIfAbsent( | 78 | + _singl.putIfAbsent( |
79 | key, () => FcBuilder<S>(isSingleton, builder, permanent, false)); | 79 | key, () => FcBuilder<S>(isSingleton, builder, permanent, false)); |
80 | } | 80 | } |
81 | 81 | ||
82 | Future<void> removeDependencyByRoute(String routeName) async { | 82 | Future<void> removeDependencyByRoute(String routeName) async { |
83 | List<String> keysToRemove = []; | 83 | List<String> keysToRemove = []; |
84 | - GetConfig.routesKey.forEach((key, value) { | ||
85 | - // if (value == routeName && value != null) { | 84 | + _routesKey.forEach((key, value) { |
86 | if (value == routeName) { | 85 | if (value == routeName) { |
87 | keysToRemove.add(key); | 86 | keysToRemove.add(key); |
88 | } | 87 | } |
@@ -92,17 +91,17 @@ class GetInstance { | @@ -92,17 +91,17 @@ class GetInstance { | ||
92 | await delete(key: element); | 91 | await delete(key: element); |
93 | }); | 92 | }); |
94 | keysToRemove.forEach((element) { | 93 | keysToRemove.forEach((element) { |
95 | - GetConfig.routesKey?.remove(element); | 94 | + _routesKey?.remove(element); |
96 | }); | 95 | }); |
97 | keysToRemove.clear(); | 96 | keysToRemove.clear(); |
98 | } | 97 | } |
99 | 98 | ||
100 | bool initDependencies<S>({String name}) { | 99 | bool initDependencies<S>({String name}) { |
101 | String key = _getKey(S, name); | 100 | String key = _getKey(S, name); |
102 | - bool isInit = GetConfig._singl[key].isInit; | 101 | + bool isInit = _singl[key].isInit; |
103 | if (!isInit) { | 102 | if (!isInit) { |
104 | startController<S>(tag: name); | 103 | startController<S>(tag: name); |
105 | - GetConfig._singl[key].isInit = true; | 104 | + _singl[key].isInit = true; |
106 | if (GetConfig.smartManagement != SmartManagement.onlyBuilder) { | 105 | if (GetConfig.smartManagement != SmartManagement.onlyBuilder) { |
107 | registerRouteInstance<S>(tag: name); | 106 | registerRouteInstance<S>(tag: name); |
108 | } | 107 | } |
@@ -111,18 +110,17 @@ class GetInstance { | @@ -111,18 +110,17 @@ class GetInstance { | ||
111 | } | 110 | } |
112 | 111 | ||
113 | void registerRouteInstance<S>({String tag}) { | 112 | void registerRouteInstance<S>({String tag}) { |
114 | - GetConfig.routesKey | ||
115 | - .putIfAbsent(_getKey(S, tag), () => GetConfig.currentRoute); | 113 | + _routesKey.putIfAbsent(_getKey(S, tag), () => GetConfig.currentRoute); |
116 | } | 114 | } |
117 | 115 | ||
118 | S findByType<S>(Type type, {String tag}) { | 116 | S findByType<S>(Type type, {String tag}) { |
119 | String key = _getKey(type, tag); | 117 | String key = _getKey(type, tag); |
120 | - return GetConfig._singl[key].getDependency() as S; | 118 | + return _singl[key].getDependency() as S; |
121 | } | 119 | } |
122 | 120 | ||
123 | void startController<S>({String tag}) { | 121 | void startController<S>({String tag}) { |
124 | String key = _getKey(S, tag); | 122 | String key = _getKey(S, tag); |
125 | - final i = GetConfig._singl[key].getDependency(); | 123 | + final i = _singl[key].getDependency(); |
126 | 124 | ||
127 | if (i is DisposableInterface) { | 125 | if (i is DisposableInterface) { |
128 | i.onStart(); | 126 | i.onStart(); |
@@ -133,15 +131,15 @@ class GetInstance { | @@ -133,15 +131,15 @@ class GetInstance { | ||
133 | // S putOrFind<S>(S Function() dep, {String tag}) { | 131 | // S putOrFind<S>(S Function() dep, {String tag}) { |
134 | // final key = _getKey(S, tag); | 132 | // final key = _getKey(S, tag); |
135 | 133 | ||
136 | - // if (GetConfig._singl.containsKey(key)) { | ||
137 | - // return GetConfig._singl[key].getDependency() as S; | 134 | + // if (_singl.containsKey(key)) { |
135 | + // return _singl[key].getDependency() as S; | ||
138 | // } else { | 136 | // } else { |
139 | - // if (GetConfig._factory.containsKey(key)) { | ||
140 | - // S _value = put<S>((GetConfig._factory[key].builder() as S), tag: tag); | 137 | + // if (_factory.containsKey(key)) { |
138 | + // S _value = put<S>((_factory[key].builder() as S), tag: tag); | ||
141 | 139 | ||
142 | // if (GetConfig.smartManagement != SmartManagement.keepFactory) { | 140 | // if (GetConfig.smartManagement != SmartManagement.keepFactory) { |
143 | - // if (!GetConfig._factory[key].fenix) { | ||
144 | - // GetConfig._factory.remove(key); | 141 | + // if (!_factory[key].fenix) { |
142 | + // _factory.remove(key); | ||
145 | // } | 143 | // } |
146 | // } | 144 | // } |
147 | // return _value; | 145 | // return _value; |
@@ -156,7 +154,7 @@ class GetInstance { | @@ -156,7 +154,7 @@ class GetInstance { | ||
156 | String key = _getKey(S, tag); | 154 | String key = _getKey(S, tag); |
157 | 155 | ||
158 | if (isRegistered<S>(tag: tag)) { | 156 | if (isRegistered<S>(tag: tag)) { |
159 | - FcBuilder builder = GetConfig._singl[key] as FcBuilder; | 157 | + FcBuilder builder = _singl[key] as FcBuilder; |
160 | if (builder == null) { | 158 | if (builder == null) { |
161 | if (tag == null) { | 159 | if (tag == null) { |
162 | throw "class ${S.toString()} is not register"; | 160 | throw "class ${S.toString()} is not register"; |
@@ -166,20 +164,20 @@ class GetInstance { | @@ -166,20 +164,20 @@ class GetInstance { | ||
166 | } | 164 | } |
167 | initDependencies<S>(name: tag); | 165 | initDependencies<S>(name: tag); |
168 | 166 | ||
169 | - return GetConfig._singl[key].getDependency() as S; | 167 | + return _singl[key].getDependency() as S; |
170 | } else { | 168 | } else { |
171 | - if (!GetConfig._factory.containsKey(key)) | 169 | + if (!_factory.containsKey(key)) |
172 | throw " $S not found. You need call put<$S>($S()) before"; | 170 | throw " $S not found. You need call put<$S>($S()) before"; |
173 | 171 | ||
174 | if (GetConfig.isLogEnable) | 172 | if (GetConfig.isLogEnable) |
175 | print('[GETX] $S instance was created at that time'); | 173 | print('[GETX] $S instance was created at that time'); |
176 | - S _value = put<S>(GetConfig._factory[key].builder() as S); | 174 | + S _value = put<S>(_factory[key].builder() as S); |
177 | 175 | ||
178 | initDependencies<S>(name: tag); | 176 | initDependencies<S>(name: tag); |
179 | 177 | ||
180 | if (GetConfig.smartManagement != SmartManagement.keepFactory && | 178 | if (GetConfig.smartManagement != SmartManagement.keepFactory && |
181 | - !GetConfig._factory[key].fenix) { | ||
182 | - GetConfig._factory.remove(key); | 179 | + !_factory[key].fenix) { |
180 | + _factory.remove(key); | ||
183 | } | 181 | } |
184 | 182 | ||
185 | return _value; | 183 | return _value; |
@@ -191,9 +189,9 @@ class GetInstance { | @@ -191,9 +189,9 @@ class GetInstance { | ||
191 | } | 189 | } |
192 | 190 | ||
193 | bool reset({bool clearFactory = true, bool clearRouteBindings = true}) { | 191 | bool reset({bool clearFactory = true, bool clearRouteBindings = true}) { |
194 | - if (clearFactory) GetConfig._factory.clear(); | ||
195 | - if (clearRouteBindings) GetConfig.routesKey.clear(); | ||
196 | - GetConfig._singl.clear(); | 192 | + if (clearFactory) _factory.clear(); |
193 | + if (clearRouteBindings) _routesKey.clear(); | ||
194 | + _singl.clear(); | ||
197 | return true; | 195 | return true; |
198 | } | 196 | } |
199 | 197 | ||
@@ -206,12 +204,12 @@ class GetInstance { | @@ -206,12 +204,12 @@ class GetInstance { | ||
206 | newKey = key; | 204 | newKey = key; |
207 | } | 205 | } |
208 | 206 | ||
209 | - if (!GetConfig._singl.containsKey(newKey)) { | 207 | + if (!_singl.containsKey(newKey)) { |
210 | print('Instance $newKey not found'); | 208 | print('Instance $newKey not found'); |
211 | return false; | 209 | return false; |
212 | } | 210 | } |
213 | 211 | ||
214 | - FcBuilder builder = GetConfig._singl[newKey] as FcBuilder; | 212 | + FcBuilder builder = _singl[newKey] as FcBuilder; |
215 | if (builder.permanent && !force) { | 213 | if (builder.permanent && !force) { |
216 | print( | 214 | print( |
217 | '[GETX] [$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.'); | 215 | '[GETX] [$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.'); |
@@ -227,23 +225,21 @@ class GetInstance { | @@ -227,23 +225,21 @@ class GetInstance { | ||
227 | if (GetConfig.isLogEnable) print('[GETX] onClose of $newKey called'); | 225 | if (GetConfig.isLogEnable) print('[GETX] onClose of $newKey called'); |
228 | } | 226 | } |
229 | 227 | ||
230 | - GetConfig._singl.removeWhere((oldKey, value) => (oldKey == newKey)); | ||
231 | - if (GetConfig._singl.containsKey(newKey)) { | 228 | + _singl.removeWhere((oldKey, value) => (oldKey == newKey)); |
229 | + if (_singl.containsKey(newKey)) { | ||
232 | print('[GETX] error on remove object $newKey'); | 230 | print('[GETX] error on remove object $newKey'); |
233 | } else { | 231 | } else { |
234 | if (GetConfig.isLogEnable) print('[GETX] $newKey deleted from memory'); | 232 | if (GetConfig.isLogEnable) print('[GETX] $newKey deleted from memory'); |
235 | } | 233 | } |
236 | - // GetConfig.routesKey?.remove(key); | 234 | + // _routesKey?.remove(key); |
237 | return true; | 235 | return true; |
238 | } | 236 | } |
239 | 237 | ||
240 | /// check if instance is registered | 238 | /// check if instance is registered |
241 | - bool isRegistered<S>({String tag}) => | ||
242 | - GetConfig._singl.containsKey(_getKey(S, tag)); | 239 | + bool isRegistered<S>({String tag}) => _singl.containsKey(_getKey(S, tag)); |
243 | 240 | ||
244 | /// check if instance is prepared | 241 | /// check if instance is prepared |
245 | - bool isPrepared<S>({String tag}) => | ||
246 | - GetConfig._factory.containsKey(_getKey(S, tag)); | 242 | + bool isPrepared<S>({String tag}) => _factory.containsKey(_getKey(S, tag)); |
247 | } | 243 | } |
248 | 244 | ||
249 | typedef FcBuilderFunc<S> = S Function(); | 245 | typedef FcBuilderFunc<S> = S Function(); |
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/src/get_interface.dart'; | 3 | +import 'package:get/src/core/get_interface.dart'; |
4 | import 'package:get/instance_manager.dart'; | 4 | import 'package:get/instance_manager.dart'; |
5 | import 'package:get/route_manager.dart'; | 5 | import 'package:get/route_manager.dart'; |
6 | import 'root/parse_route.dart'; | 6 | import 'root/parse_route.dart'; |
@@ -184,13 +184,9 @@ class GetMaterialApp extends StatelessWidget { | @@ -184,13 +184,9 @@ class GetMaterialApp extends StatelessWidget { | ||
184 | initState: (i) { | 184 | initState: (i) { |
185 | print( | 185 | print( |
186 | '[GETX] INITIALIZED: If you need help, join our community support channels: https://tinyurl.com/y3cp88l3'); | 186 | '[GETX] INITIALIZED: If you need help, join our community support channels: https://tinyurl.com/y3cp88l3'); |
187 | - if (locale != null) { | ||
188 | - Get.locale = locale; | ||
189 | - } | 187 | + if (locale != null) Get.locale = locale; |
190 | 188 | ||
191 | - if (fallbackLocale != null) { | ||
192 | - Get.fallbackLocale = fallbackLocale; | ||
193 | - } | 189 | + if (fallbackLocale != null) Get.fallbackLocale = fallbackLocale; |
194 | 190 | ||
195 | if (translations != null) { | 191 | if (translations != null) { |
196 | Get.translations = translations.keys; | 192 | Get.translations = translations.keys; |
@@ -7,7 +7,7 @@ export 'root/root_widget.dart'; | @@ -7,7 +7,7 @@ export 'root/root_widget.dart'; | ||
7 | export 'snackbar/snack_route.dart'; | 7 | export 'snackbar/snack_route.dart'; |
8 | export 'bottomsheet/bottomsheet.dart'; | 8 | export 'bottomsheet/bottomsheet.dart'; |
9 | export 'snackbar/snack.dart'; | 9 | export 'snackbar/snack.dart'; |
10 | -export '../get_main.dart'; | 10 | +export '../core/get_main.dart'; |
11 | export 'routes/default_route.dart'; | 11 | export 'routes/default_route.dart'; |
12 | export 'root/smart_management.dart'; | 12 | export 'root/smart_management.dart'; |
13 | export 'extension_navigation.dart'; | 13 | export 'extension_navigation.dart'; |
@@ -4,7 +4,7 @@ import 'package:flutter/cupertino.dart'; | @@ -4,7 +4,7 @@ import 'package:flutter/cupertino.dart'; | ||
4 | import 'package:flutter/gestures.dart'; | 4 | import 'package:flutter/gestures.dart'; |
5 | import 'package:flutter/material.dart'; | 5 | import 'package:flutter/material.dart'; |
6 | import 'package:get/route_manager.dart'; | 6 | import 'package:get/route_manager.dart'; |
7 | -import 'package:get/src/get_main.dart'; | 7 | +import 'package:get/src/core/get_main.dart'; |
8 | import 'package:get/src/instance/get_instance.dart'; | 8 | import 'package:get/src/instance/get_instance.dart'; |
9 | import 'package:get/utils.dart'; | 9 | import 'package:get/utils.dart'; |
10 | import 'bindings_interface.dart'; | 10 | import 'bindings_interface.dart'; |
@@ -70,13 +70,13 @@ class _RxImpl<T> implements RxInterface<T> { | @@ -70,13 +70,13 @@ class _RxImpl<T> implements RxInterface<T> { | ||
70 | Stream<R> map<R>(R mapper(T data)) => stream.map(mapper); | 70 | Stream<R> map<R>(R mapper(T data)) => stream.map(mapper); |
71 | } | 71 | } |
72 | 72 | ||
73 | -class RxMap<K, V> extends RxInterface implements Map<K, V> { | 73 | +class RxMap<K, V> extends RxInterface<Map<K, V>> implements Map<K, V> { |
74 | RxMap([Map<K, V> initial]) { | 74 | RxMap([Map<K, V> initial]) { |
75 | _value = initial; | 75 | _value = initial; |
76 | } | 76 | } |
77 | 77 | ||
78 | @override | 78 | @override |
79 | - StreamController subject = StreamController<Map<K, V>>.broadcast(); | 79 | + StreamController<Map<K, V>> subject = StreamController<Map<K, V>>.broadcast(); |
80 | final Map<Stream<Map<K, V>>, StreamSubscription> _subscriptions = {}; | 80 | final Map<Stream<Map<K, V>>, StreamSubscription> _subscriptions = {}; |
81 | 81 | ||
82 | Map<K, V> _value; | 82 | Map<K, V> _value; |
@@ -248,7 +248,7 @@ class RxMap<K, V> extends RxInterface implements Map<K, V> { | @@ -248,7 +248,7 @@ class RxMap<K, V> extends RxInterface implements Map<K, V> { | ||
248 | } | 248 | } |
249 | 249 | ||
250 | /// Create a list similar to `List<T>` | 250 | /// Create a list similar to `List<T>` |
251 | -class RxList<E> extends Iterable<E> implements RxInterface<E> { | 251 | +class RxList<E> extends Iterable<E> implements RxInterface<List<E>> { |
252 | RxList([List<E> initial]) { | 252 | RxList([List<E> initial]) { |
253 | _list = initial; | 253 | _list = initial; |
254 | } | 254 | } |
@@ -266,8 +266,8 @@ class RxList<E> extends Iterable<E> implements RxInterface<E> { | @@ -266,8 +266,8 @@ class RxList<E> extends Iterable<E> implements RxInterface<E> { | ||
266 | @override | 266 | @override |
267 | bool get isNotEmpty => value.isNotEmpty; | 267 | bool get isNotEmpty => value.isNotEmpty; |
268 | 268 | ||
269 | - StreamController<E> subject = StreamController<E>.broadcast(); | ||
270 | - Map<Stream<E>, StreamSubscription> _subscriptions = Map(); | 269 | + StreamController<List<E>> subject = StreamController<List<E>>.broadcast(); |
270 | + Map<Stream<List<E>>, StreamSubscription> _subscriptions = Map(); | ||
271 | 271 | ||
272 | /// Adds [item] only if [condition] resolves to true. | 272 | /// Adds [item] only if [condition] resolves to true. |
273 | void addIf(condition, E item) { | 273 | void addIf(condition, E item) { |
@@ -283,7 +283,7 @@ class RxList<E> extends Iterable<E> implements RxInterface<E> { | @@ -283,7 +283,7 @@ class RxList<E> extends Iterable<E> implements RxInterface<E> { | ||
283 | 283 | ||
284 | operator []=(int index, E val) { | 284 | operator []=(int index, E val) { |
285 | _list[index] = val; | 285 | _list[index] = val; |
286 | - subject.add(val); | 286 | + subject.add(_list); |
287 | } | 287 | } |
288 | 288 | ||
289 | E operator [](int index) { | 289 | E operator [](int index) { |
@@ -292,12 +292,12 @@ class RxList<E> extends Iterable<E> implements RxInterface<E> { | @@ -292,12 +292,12 @@ class RxList<E> extends Iterable<E> implements RxInterface<E> { | ||
292 | 292 | ||
293 | void add(E item) { | 293 | void add(E item) { |
294 | _list.add(item); | 294 | _list.add(item); |
295 | - subject.add(item); | 295 | + subject.add(_list); |
296 | } | 296 | } |
297 | 297 | ||
298 | void addAll(Iterable<E> item) { | 298 | void addAll(Iterable<E> item) { |
299 | _list.addAll(item); | 299 | _list.addAll(item); |
300 | - subject.add(null); | 300 | + subject.add(_list); |
301 | } | 301 | } |
302 | 302 | ||
303 | /// Adds only if [item] is not null. | 303 | /// Adds only if [item] is not null. |
@@ -312,12 +312,12 @@ class RxList<E> extends Iterable<E> implements RxInterface<E> { | @@ -312,12 +312,12 @@ class RxList<E> extends Iterable<E> implements RxInterface<E> { | ||
312 | 312 | ||
313 | void insert(int index, E item) { | 313 | void insert(int index, E item) { |
314 | _list.insert(index, item); | 314 | _list.insert(index, item); |
315 | - subject.add(item); | 315 | + subject.add(_list); |
316 | } | 316 | } |
317 | 317 | ||
318 | void insertAll(int index, Iterable<E> iterable) { | 318 | void insertAll(int index, Iterable<E> iterable) { |
319 | _list.insertAll(index, iterable); | 319 | _list.insertAll(index, iterable); |
320 | - subject.add(iterable.last); | 320 | + subject.add(_list); |
321 | } | 321 | } |
322 | 322 | ||
323 | int get length => value.length; | 323 | int get length => value.length; |
@@ -337,34 +337,34 @@ class RxList<E> extends Iterable<E> implements RxInterface<E> { | @@ -337,34 +337,34 @@ class RxList<E> extends Iterable<E> implements RxInterface<E> { | ||
337 | 337 | ||
338 | E removeAt(int index) { | 338 | E removeAt(int index) { |
339 | E item = _list.removeAt(index); | 339 | E item = _list.removeAt(index); |
340 | - subject.add(item); | 340 | + subject.add(_list); |
341 | return item; | 341 | return item; |
342 | } | 342 | } |
343 | 343 | ||
344 | E removeLast() { | 344 | E removeLast() { |
345 | E item = _list.removeLast(); | 345 | E item = _list.removeLast(); |
346 | - subject.add(item); | 346 | + subject.add(_list); |
347 | return item; | 347 | return item; |
348 | } | 348 | } |
349 | 349 | ||
350 | void removeRange(int start, int end) { | 350 | void removeRange(int start, int end) { |
351 | _list.removeRange(start, end); | 351 | _list.removeRange(start, end); |
352 | - subject.add(null); | 352 | + subject.add(_list); |
353 | } | 353 | } |
354 | 354 | ||
355 | void removeWhere(bool Function(E) test) { | 355 | void removeWhere(bool Function(E) test) { |
356 | _list.removeWhere(test); | 356 | _list.removeWhere(test); |
357 | - subject.add(null); | 357 | + subject.add(_list); |
358 | } | 358 | } |
359 | 359 | ||
360 | void clear() { | 360 | void clear() { |
361 | _list.clear(); | 361 | _list.clear(); |
362 | - subject.add(null); | 362 | + subject.add(_list); |
363 | } | 363 | } |
364 | 364 | ||
365 | void sort([int compare(E a, E b)]) { | 365 | void sort([int compare(E a, E b)]) { |
366 | _list.sort(); | 366 | _list.sort(); |
367 | - subject.add(null); | 367 | + subject.add(_list); |
368 | } | 368 | } |
369 | 369 | ||
370 | close() { | 370 | close() { |
@@ -401,7 +401,7 @@ class RxList<E> extends Iterable<E> implements RxInterface<E> { | @@ -401,7 +401,7 @@ class RxList<E> extends Iterable<E> implements RxInterface<E> { | ||
401 | 401 | ||
402 | String get string => value.toString(); | 402 | String get string => value.toString(); |
403 | 403 | ||
404 | - addListener(Stream<E> rxGetx) { | 404 | + addListener(Stream<List<E>> rxGetx) { |
405 | if (_subscriptions.containsKey(rxGetx)) { | 405 | if (_subscriptions.containsKey(rxGetx)) { |
406 | return; | 406 | return; |
407 | } | 407 | } |
@@ -413,12 +413,12 @@ class RxList<E> extends Iterable<E> implements RxInterface<E> { | @@ -413,12 +413,12 @@ class RxList<E> extends Iterable<E> implements RxInterface<E> { | ||
413 | set value(Iterable<E> val) { | 413 | set value(Iterable<E> val) { |
414 | if (_list == val) return; | 414 | if (_list == val) return; |
415 | _list = val; | 415 | _list = val; |
416 | - subject.add(null); | 416 | + subject.add(_list); |
417 | } | 417 | } |
418 | 418 | ||
419 | - Stream<E> get stream => subject.stream; | 419 | + Stream<List<E>> get stream => subject.stream; |
420 | 420 | ||
421 | - StreamSubscription<E> listen(void Function(E) onData, | 421 | + StreamSubscription<List<E>> listen(void Function(List<E>) onData, |
422 | {Function onError, void Function() onDone, bool cancelOnError}) => | 422 | {Function onError, void Function() onDone, bool cancelOnError}) => |
423 | stream.listen(onData, onError: onError, onDone: onDone); | 423 | stream.listen(onData, onError: onError, onDone: onDone); |
424 | 424 |
@@ -6,12 +6,12 @@ abstract class RxInterface<T> { | @@ -6,12 +6,12 @@ abstract class RxInterface<T> { | ||
6 | RxInterface([T initial]); | 6 | RxInterface([T initial]); |
7 | 7 | ||
8 | /// add listener to stream | 8 | /// add listener to stream |
9 | - addListener(Stream<T> rxGetx); | 9 | + void addListener(Stream<T> rxGetx); |
10 | 10 | ||
11 | bool get canUpdate; | 11 | bool get canUpdate; |
12 | 12 | ||
13 | /// close stream | 13 | /// close stream |
14 | - close() { | 14 | + void close() { |
15 | subject?.close(); | 15 | subject?.close(); |
16 | } | 16 | } |
17 | 17 | ||
@@ -21,6 +21,9 @@ abstract class RxInterface<T> { | @@ -21,6 +21,9 @@ abstract class RxInterface<T> { | ||
21 | StreamSubscription<T> listen(ValueCallback<T> callback); | 21 | StreamSubscription<T> listen(ValueCallback<T> callback); |
22 | } | 22 | } |
23 | 23 | ||
24 | +/// Unlike GetxController, which serves to control events on each of its pages, | ||
25 | +/// GetxService is not automatically disposed. It is ideal for situations where, | ||
26 | +/// once started, that service will remain in memory, such as Auth control for example. | ||
24 | abstract class GetxService extends DisposableInterface {} | 27 | abstract class GetxService extends DisposableInterface {} |
25 | 28 | ||
26 | abstract class DisposableInterface { | 29 | abstract class DisposableInterface { |
1 | name: get | 1 | name: get |
2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with GetX. | 2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with GetX. |
3 | -version: 3.4.3 | 3 | +version: 3.4.4 |
4 | homepage: https://github.com/jonataslaw/get | 4 | homepage: https://github.com/jonataslaw/get |
5 | 5 | ||
6 | environment: | 6 | environment: |
-
Please register or login to post a comment