Showing
15 changed files
with
167 additions
and
168 deletions
1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
2 | import 'package:get/get.dart'; | 2 | import 'package:get/get.dart'; |
3 | 3 | ||
4 | +import 'lang/translation_service.dart'; | ||
5 | +import 'routes/app_pages.dart'; | ||
6 | +import 'shared/logger/logger_utils.dart'; | ||
7 | + | ||
4 | void main() { | 8 | void main() { |
5 | - //MyBindings().dependencies(); | ||
6 | - runApp( | ||
7 | - Binds( | ||
8 | - binds: [ | ||
9 | - Bind.lazyPut(() => Controller()), | ||
10 | - Bind.lazyPut(() => Controller2()), | ||
11 | - ], | ||
12 | - child: GetMaterialApp( | ||
13 | - home: Home(), | ||
14 | - ), | ||
15 | - ), | ||
16 | - ); | 9 | + runApp(MyApp()); |
17 | } | 10 | } |
18 | 11 | ||
12 | +class MyApp extends StatelessWidget { | ||
13 | + const MyApp({Key? key}) : super(key: key); | ||
19 | 14 | ||
20 | - | ||
21 | -class MyBindings extends Binding { | ||
22 | @override | 15 | @override |
23 | - List<Bind> dependencies() { | ||
24 | - return [ | ||
25 | - Bind.put(Controller()), | ||
26 | - Bind.put(Controller2()), | ||
27 | - ]; | 16 | + Widget build(BuildContext context) { |
17 | + return GetMaterialApp.router( | ||
18 | + debugShowCheckedModeBanner: false, | ||
19 | + enableLog: true, | ||
20 | + logWriterCallback: Logger.write, | ||
21 | + // initialRoute: AppPages.INITIAL, | ||
22 | + getPages: AppPages.routes, | ||
23 | + locale: TranslationService.locale, | ||
24 | + fallbackLocale: TranslationService.fallbackLocale, | ||
25 | + translations: TranslationService(), | ||
26 | + ); | ||
28 | } | 27 | } |
29 | } | 28 | } |
30 | 29 | ||
31 | -class Controller extends GetxController { | ||
32 | - final count = 0.obs; | ||
33 | - void increment() { | ||
34 | - count.value++; | ||
35 | - update(); | ||
36 | - } | ||
37 | -} | 30 | +/// Nav 2 snippet |
31 | +// void main() { | ||
32 | +// runApp(MyApp()); | ||
33 | +// } | ||
38 | 34 | ||
39 | -class Controller2 extends GetxController { | ||
40 | - final count = 0.obs; | 35 | +// class MyApp extends StatelessWidget { |
36 | +// MyApp({Key? key}) : super(key: key); | ||
41 | 37 | ||
42 | - Controller2(); | ||
43 | - void increment() { | ||
44 | - count.value++; | ||
45 | - update(); | ||
46 | - } | ||
47 | -} | 38 | +// @override |
39 | +// Widget build(BuildContext context) { | ||
40 | +// return GetMaterialApp.router( | ||
41 | +// getPages: [ | ||
42 | +// GetPage( | ||
43 | +// participatesInRootNavigator: true, | ||
44 | +// name: '/first', | ||
45 | +// page: () => First()), | ||
46 | +// GetPage( | ||
47 | +// name: '/second', | ||
48 | +// page: () => Second(), | ||
49 | +// ), | ||
50 | +// GetPage( | ||
51 | +// name: '/third', | ||
52 | +// page: () => Third(), | ||
53 | +// ), | ||
54 | +// ], | ||
55 | +// debugShowCheckedModeBanner: false, | ||
56 | +// ); | ||
57 | +// } | ||
58 | +// } | ||
48 | 59 | ||
49 | -class Home extends ObxStatelessWidget { | ||
50 | - const Home({Key? key}) : super(key: key); | ||
51 | - @override | ||
52 | - Widget build(BuildContext context) { | ||
53 | - print('sasasasa'); | ||
54 | - return Scaffold( | ||
55 | - appBar: AppBar(title: Text("counter")), | ||
56 | - body: Builder(builder: (context) { | ||
57 | - return Center( | ||
58 | - child: Column( | ||
59 | - mainAxisAlignment: MainAxisAlignment.center, | ||
60 | - children: [ | ||
61 | - Builder(builder: (context) { | ||
62 | - print('builder'); | ||
63 | - final controller = context.listen<Controller>(); | ||
64 | - return Text('${controller.count.value}'); | ||
65 | - }), | ||
66 | - ElevatedButton( | ||
67 | - child: Text('Next Route'), | ||
68 | - onPressed: () { | ||
69 | - Get.to(() => Second()); | ||
70 | - }, | ||
71 | - ), | ||
72 | - ], | ||
73 | - ), | ||
74 | - ); | ||
75 | - }), | ||
76 | - floatingActionButton: FloatingActionButton( | ||
77 | - child: Icon(Icons.add), | ||
78 | - onPressed: () { | ||
79 | - Get.find<Controller>().increment(); | ||
80 | - }, | ||
81 | - ), | ||
82 | - ); | ||
83 | - } | ||
84 | -} | 60 | +// class First extends StatelessWidget { |
61 | +// @override | ||
62 | +// Widget build(BuildContext context) { | ||
63 | +// return Scaffold( | ||
64 | +// appBar: AppBar( | ||
65 | +// title: Text('page one'), | ||
66 | +// leading: IconButton( | ||
67 | +// icon: Icon(Icons.more), | ||
68 | +// onPressed: () { | ||
69 | +// Get.changeTheme( | ||
70 | +// context.isDarkMode ? ThemeData.light() : ThemeData.dark()); | ||
71 | +// }, | ||
72 | +// ), | ||
73 | +// ), | ||
74 | +// body: Center( | ||
75 | +// child: Container( | ||
76 | +// height: 300, | ||
77 | +// width: 300, | ||
78 | +// child: ElevatedButton( | ||
79 | +// onPressed: () {}, | ||
80 | +// child: Text('next screen'), | ||
81 | +// ), | ||
82 | +// ), | ||
83 | +// ), | ||
84 | +// ); | ||
85 | +// } | ||
86 | +// } | ||
85 | 87 | ||
86 | -class Second extends StatelessWidget { | ||
87 | - @override | ||
88 | - Widget build(BuildContext context) { | ||
89 | - return Scaffold( | ||
90 | - appBar: AppBar(), | ||
91 | - floatingActionButton: FloatingActionButton( | ||
92 | - onPressed: () { | ||
93 | - context.get<Controller2>().increment(); | ||
94 | - }, | ||
95 | - ), | ||
96 | - body: Center( | ||
97 | - child: Builder(builder: (context) { | ||
98 | - final ctrl = context.listen<Controller2>(); | ||
99 | - return Text("${ctrl.count}"); | ||
100 | - }), | ||
101 | - ), | ||
102 | - ); | ||
103 | - } | ||
104 | -} | 88 | +// class Second extends StatelessWidget { |
89 | +// @override | ||
90 | +// Widget build(BuildContext context) { | ||
91 | +// return Scaffold( | ||
92 | +// appBar: AppBar( | ||
93 | +// title: Text('page two ${Get.parameters["id"]}'), | ||
94 | +// ), | ||
95 | +// body: Center( | ||
96 | +// child: Container( | ||
97 | +// height: 300, | ||
98 | +// width: 300, | ||
99 | +// child: ElevatedButton( | ||
100 | +// onPressed: () {}, | ||
101 | +// child: Text('next screen'), | ||
102 | +// ), | ||
103 | +// ), | ||
104 | +// ), | ||
105 | +// ); | ||
106 | +// } | ||
107 | +// } | ||
108 | + | ||
109 | +// class Third extends StatelessWidget { | ||
110 | +// @override | ||
111 | +// Widget build(BuildContext context) { | ||
112 | +// return Scaffold( | ||
113 | +// backgroundColor: Colors.red, | ||
114 | +// appBar: AppBar( | ||
115 | +// title: Text('page three'), | ||
116 | +// ), | ||
117 | +// body: Center( | ||
118 | +// child: Container( | ||
119 | +// height: 300, | ||
120 | +// width: 300, | ||
121 | +// child: ElevatedButton( | ||
122 | +// onPressed: () {}, | ||
123 | +// child: Text('go to first screen'), | ||
124 | +// ), | ||
125 | +// ), | ||
126 | +// ), | ||
127 | +// ); | ||
128 | +// } | ||
129 | +// } |
1 | +// ignore: one_member_abstracts | ||
1 | import 'get_instance.dart'; | 2 | import 'get_instance.dart'; |
2 | 3 | ||
4 | +// ignore: one_member_abstracts | ||
5 | +abstract class BindingsInterface<T> { | ||
6 | + T dependencies(); | ||
7 | +} | ||
8 | + | ||
3 | /// [Bindings] should be extended or implemented. | 9 | /// [Bindings] should be extended or implemented. |
4 | /// When using `GetMaterialApp`, all `GetPage`s and navigation | 10 | /// When using `GetMaterialApp`, all `GetPage`s and navigation |
5 | /// methods (like Get.to()) have a `binding` property that takes an | 11 | /// methods (like Get.to()) have a `binding` property that takes an |
@@ -7,8 +13,9 @@ import 'get_instance.dart'; | @@ -7,8 +13,9 @@ import 'get_instance.dart'; | ||
7 | /// dependencies() (via Get.put()) for the Route you are opening. | 13 | /// dependencies() (via Get.put()) for the Route you are opening. |
8 | // ignore: one_member_abstracts | 14 | // ignore: one_member_abstracts |
9 | @Deprecated('Use Binding instead') | 15 | @Deprecated('Use Binding instead') |
10 | -abstract class Bindings<T> { | ||
11 | - T dependencies(); | 16 | +abstract class Bindings extends BindingsInterface<void> { |
17 | + @override | ||
18 | + void dependencies(); | ||
12 | } | 19 | } |
13 | 20 | ||
14 | /// Simplifies Bindings generation from a single callback. | 21 | /// Simplifies Bindings generation from a single callback. |
@@ -59,8 +66,4 @@ class BindingsBuilder<T> extends Bindings { | @@ -59,8 +66,4 @@ class BindingsBuilder<T> extends Bindings { | ||
59 | } | 66 | } |
60 | } | 67 | } |
61 | 68 | ||
62 | -// abstract class INavigation {} | ||
63 | -// typedef Snack = Function(); | ||
64 | -// typedef Modal = Function(); | ||
65 | -// typedef Route = Function(); | ||
66 | typedef BindingBuilderCallback = void Function(); | 69 | typedef BindingBuilderCallback = void Function(); |
@@ -2,10 +2,10 @@ import 'dart:ui' as ui; | @@ -2,10 +2,10 @@ import 'dart:ui' as ui; | ||
2 | 2 | ||
3 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
4 | import 'package:flutter/scheduler.dart'; | 4 | import 'package:flutter/scheduler.dart'; |
5 | -import 'package:get/get_state_manager/src/simple/get_state.dart'; | ||
6 | 5 | ||
7 | import '../../get_core/get_core.dart'; | 6 | import '../../get_core/get_core.dart'; |
8 | import '../../get_instance/src/bindings_interface.dart'; | 7 | import '../../get_instance/src/bindings_interface.dart'; |
8 | +import '../../get_state_manager/src/simple/get_state.dart'; | ||
9 | import '../../get_utils/get_utils.dart'; | 9 | import '../../get_utils/get_utils.dart'; |
10 | import '../get_navigation.dart'; | 10 | import '../get_navigation.dart'; |
11 | import 'dialog/dialog_route.dart'; | 11 | import 'dialog/dialog_route.dart'; |
@@ -51,7 +51,7 @@ class GetCupertinoApp extends StatelessWidget { | @@ -51,7 +51,7 @@ class GetCupertinoApp extends StatelessWidget { | ||
51 | final LogWriterCallback? logWriterCallback; | 51 | final LogWriterCallback? logWriterCallback; |
52 | final bool? popGesture; | 52 | final bool? popGesture; |
53 | final SmartManagement smartManagement; | 53 | final SmartManagement smartManagement; |
54 | - final Bindings? initialBinding; | 54 | + final BindingsInterface? initialBinding; |
55 | final Duration? transitionDuration; | 55 | final Duration? transitionDuration; |
56 | final bool? defaultGlobalState; | 56 | final bool? defaultGlobalState; |
57 | final List<GetPage>? getPages; | 57 | final List<GetPage>? getPages; |
@@ -56,7 +56,7 @@ class GetMaterialApp extends StatelessWidget { | @@ -56,7 +56,7 @@ class GetMaterialApp extends StatelessWidget { | ||
56 | final LogWriterCallback? logWriterCallback; | 56 | final LogWriterCallback? logWriterCallback; |
57 | final bool? popGesture; | 57 | final bool? popGesture; |
58 | final SmartManagement smartManagement; | 58 | final SmartManagement smartManagement; |
59 | - final Bindings? initialBinding; | 59 | + final BindingsInterface? initialBinding; |
60 | final Duration? transitionDuration; | 60 | final Duration? transitionDuration; |
61 | final bool? defaultGlobalState; | 61 | final bool? defaultGlobalState; |
62 | final List<GetPage>? getPages; | 62 | final List<GetPage>? getPages; |
@@ -61,7 +61,7 @@ class GetPageRoute<T> extends PageRoute<T> //MaterialPageRoute<T> | @@ -61,7 +61,7 @@ class GetPageRoute<T> extends PageRoute<T> //MaterialPageRoute<T> | ||
61 | final String? routeName; | 61 | final String? routeName; |
62 | //final String reference; | 62 | //final String reference; |
63 | final CustomTransition? customTransition; | 63 | final CustomTransition? customTransition; |
64 | - final Binding? binding; | 64 | + final BindingsInterface? binding; |
65 | final Map<String, String>? parameter; | 65 | final Map<String, String>? parameter; |
66 | final List<Bind>? binds; | 66 | final List<Bind>? binds; |
67 | 67 | ||
@@ -101,14 +101,32 @@ class GetPageRoute<T> extends PageRoute<T> //MaterialPageRoute<T> | @@ -101,14 +101,32 @@ class GetPageRoute<T> extends PageRoute<T> //MaterialPageRoute<T> | ||
101 | if (_child != null) return _child!; | 101 | if (_child != null) return _child!; |
102 | final middlewareRunner = MiddlewareRunner(middlewares); | 102 | final middlewareRunner = MiddlewareRunner(middlewares); |
103 | 103 | ||
104 | - final localbindings = [ | 104 | + final localbinds = [ |
105 | if (binds != null) ...binds!, | 105 | if (binds != null) ...binds!, |
106 | - if (binding != null) ...binding!.dependencies(), | ||
107 | ]; | 106 | ]; |
108 | - final bindingsToBind = middlewareRunner.runOnBindingsStart(localbindings); | 107 | + |
108 | + final localbindings = [ | ||
109 | + if (binding != null) ...<BindingsInterface>[binding!], | ||
110 | + ]; | ||
111 | + | ||
112 | + final bindingsToBind = middlewareRunner | ||
113 | + .runOnBindingsStart(binding != null ? localbindings : localbinds); | ||
114 | + | ||
115 | + /// Retrocompatibility workaround, remove this when Bindings api | ||
116 | + /// have been removed | ||
117 | + if (bindingsToBind != null && | ||
118 | + bindingsToBind is! List<Bind> && | ||
119 | + bindingsToBind is List<BindingsInterface>) { | ||
120 | + for (final binding in bindingsToBind) { | ||
121 | + binding.dependencies(); | ||
122 | + } | ||
123 | + } | ||
109 | 124 | ||
110 | final pageToBuild = middlewareRunner.runOnPageBuildStart(page)!; | 125 | final pageToBuild = middlewareRunner.runOnPageBuildStart(page)!; |
111 | - if (bindingsToBind != null && bindingsToBind.isNotEmpty) { | 126 | + |
127 | + if (bindingsToBind != null && | ||
128 | + bindingsToBind.isNotEmpty && | ||
129 | + bindingsToBind is List<Bind>) { | ||
112 | _child = Binds( | 130 | _child = Binds( |
113 | child: middlewareRunner.runOnPageBuilt(pageToBuild()), | 131 | child: middlewareRunner.runOnPageBuilt(pageToBuild()), |
114 | binds: bindingsToBind, | 132 | binds: bindingsToBind, |
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; | @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; | ||
2 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
3 | 3 | ||
4 | import '../../../get_core/src/get_main.dart'; | 4 | import '../../../get_core/src/get_main.dart'; |
5 | +import '../../../get_instance/src/bindings_interface.dart'; | ||
5 | import '../../../get_state_manager/src/simple/get_state.dart'; | 6 | import '../../../get_state_manager/src/simple/get_state.dart'; |
6 | import '../../get_navigation.dart'; | 7 | import '../../get_navigation.dart'; |
7 | 8 | ||
@@ -17,7 +18,7 @@ class GetPage<T> extends Page<T> { | @@ -17,7 +18,7 @@ class GetPage<T> extends Page<T> { | ||
17 | final bool maintainState; | 18 | final bool maintainState; |
18 | final bool opaque; | 19 | final bool opaque; |
19 | final double Function(BuildContext context)? gestureWidth; | 20 | final double Function(BuildContext context)? gestureWidth; |
20 | - final Binding? binding; | 21 | + final BindingsInterface? binding; |
21 | final List<Bind> binds; | 22 | final List<Bind> binds; |
22 | final CustomTransition? customTransition; | 23 | final CustomTransition? customTransition; |
23 | final Duration? transitionDuration; | 24 | final Duration? transitionDuration; |
@@ -87,7 +88,7 @@ class GetPage<T> extends Page<T> { | @@ -87,7 +88,7 @@ class GetPage<T> extends Page<T> { | ||
87 | Alignment? alignment, | 88 | Alignment? alignment, |
88 | bool? maintainState, | 89 | bool? maintainState, |
89 | bool? opaque, | 90 | bool? opaque, |
90 | - Binding? binding, | 91 | + BindingsInterface? binding, |
91 | List<Bind>? binds, | 92 | List<Bind>? binds, |
92 | CustomTransition? customTransition, | 93 | CustomTransition? customTransition, |
93 | Duration? transitionDuration, | 94 | Duration? transitionDuration, |
1 | import 'package:flutter/cupertino.dart'; | 1 | import 'package:flutter/cupertino.dart'; |
2 | import 'package:flutter/foundation.dart'; | 2 | import 'package:flutter/foundation.dart'; |
3 | + | ||
3 | import '../../../get.dart'; | 4 | import '../../../get.dart'; |
4 | 5 | ||
5 | abstract class _RouteMiddleware { | 6 | abstract class _RouteMiddleware { |
@@ -77,7 +78,7 @@ abstract class _RouteMiddleware { | @@ -77,7 +78,7 @@ abstract class _RouteMiddleware { | ||
77 | /// } | 78 | /// } |
78 | /// ``` | 79 | /// ``` |
79 | /// {@end-tool} | 80 | /// {@end-tool} |
80 | - List<Bind>? onBindingsStart(List<Bind> bindings); | 81 | + List<R>? onBindingsStart<R>(List<R> bindings); |
81 | 82 | ||
82 | /// This function will be called right after the [Bindings] are initialize. | 83 | /// This function will be called right after the [Bindings] are initialize. |
83 | GetPageBuilder? onPageBuildStart(GetPageBuilder page); | 84 | GetPageBuilder? onPageBuildStart(GetPageBuilder page); |
@@ -107,7 +108,7 @@ class GetMiddleware implements _RouteMiddleware { | @@ -107,7 +108,7 @@ class GetMiddleware implements _RouteMiddleware { | ||
107 | GetPage? onPageCalled(GetPage? page) => page; | 108 | GetPage? onPageCalled(GetPage? page) => page; |
108 | 109 | ||
109 | @override | 110 | @override |
110 | - List<Bind>? onBindingsStart(List<Bind>? bindings) => bindings; | 111 | + List<R>? onBindingsStart<R>(List<R>? bindings) => bindings; |
111 | 112 | ||
112 | @override | 113 | @override |
113 | GetPageBuilder? onPageBuildStart(GetPageBuilder? page) => page; | 114 | GetPageBuilder? onPageBuildStart(GetPageBuilder? page) => page; |
@@ -155,7 +156,7 @@ class MiddlewareRunner { | @@ -155,7 +156,7 @@ class MiddlewareRunner { | ||
155 | return to; | 156 | return to; |
156 | } | 157 | } |
157 | 158 | ||
158 | - List<Bind>? runOnBindingsStart(List<Bind>? bindings) { | 159 | + List<R>? runOnBindingsStart<R>(List<R>? bindings) { |
159 | _getMiddlewares().forEach((element) { | 160 | _getMiddlewares().forEach((element) { |
160 | bindings = element.onBindingsStart(bindings); | 161 | bindings = element.onBindingsStart(bindings); |
161 | }); | 162 | }); |
@@ -2,8 +2,6 @@ library rx_stream; | @@ -2,8 +2,6 @@ library rx_stream; | ||
2 | 2 | ||
3 | import 'dart:async'; | 3 | import 'dart:async'; |
4 | 4 | ||
5 | -import 'package:get/get_state_manager/src/simple/list_notifier.dart'; | ||
6 | - | ||
7 | import '../rx_typedefs/rx_typedefs.dart'; | 5 | import '../rx_typedefs/rx_typedefs.dart'; |
8 | import '../rx_types/rx_types.dart'; | 6 | import '../rx_types/rx_types.dart'; |
9 | 7 |
@@ -292,12 +292,9 @@ extension RxBoolExt on Rx<bool> { | @@ -292,12 +292,9 @@ extension RxBoolExt on Rx<bool> { | ||
292 | 292 | ||
293 | /// Toggles the bool [value] between false and true. | 293 | /// Toggles the bool [value] between false and true. |
294 | /// A shortcut for `flag.value = !flag.value;` | 294 | /// A shortcut for `flag.value = !flag.value;` |
295 | - /// FIXME: why return this? fluent interface is not | ||
296 | - /// not really a dart thing since we have '..' operator | ||
297 | - // ignore: avoid_returning_this | ||
298 | - Rx<bool> toggle() { | 295 | + void toggle() { |
299 | subject.add(!value); | 296 | subject.add(!value); |
300 | - return this; | 297 | + // return this; |
301 | } | 298 | } |
302 | } | 299 | } |
303 | 300 | ||
@@ -324,13 +321,10 @@ extension RxnBoolExt on Rx<bool?> { | @@ -324,13 +321,10 @@ extension RxnBoolExt on Rx<bool?> { | ||
324 | 321 | ||
325 | /// Toggles the bool [value] between false and true. | 322 | /// Toggles the bool [value] between false and true. |
326 | /// A shortcut for `flag.value = !flag.value;` | 323 | /// A shortcut for `flag.value = !flag.value;` |
327 | - /// FIXME: why return this? fluent interface is not | ||
328 | - /// not really a dart thing since we have '..' operator | ||
329 | - // ignore: avoid_returning_this | ||
330 | - Rx<bool?>? toggle() { | 324 | + void toggle() { |
331 | if (value != null) { | 325 | if (value != null) { |
332 | subject.add(!value!); | 326 | subject.add(!value!); |
333 | - return this; | 327 | + // return this; |
334 | } | 328 | } |
335 | } | 329 | } |
336 | } | 330 | } |
@@ -4,7 +4,7 @@ import 'dart:async'; | @@ -4,7 +4,7 @@ import 'dart:async'; | ||
4 | import 'dart:collection'; | 4 | import 'dart:collection'; |
5 | 5 | ||
6 | import 'package:flutter/foundation.dart'; | 6 | import 'package:flutter/foundation.dart'; |
7 | -import 'package:get/get_state_manager/src/simple/list_notifier.dart'; | 7 | + |
8 | import '../rx_stream/rx_stream.dart'; | 8 | import '../rx_stream/rx_stream.dart'; |
9 | import '../rx_typedefs/rx_typedefs.dart'; | 9 | import '../rx_typedefs/rx_typedefs.dart'; |
10 | 10 | ||
@@ -12,7 +12,6 @@ part 'rx_core/rx_impl.dart'; | @@ -12,7 +12,6 @@ part 'rx_core/rx_impl.dart'; | ||
12 | part 'rx_core/rx_interface.dart'; | 12 | part 'rx_core/rx_interface.dart'; |
13 | part 'rx_core/rx_num.dart'; | 13 | part 'rx_core/rx_num.dart'; |
14 | part 'rx_core/rx_string.dart'; | 14 | part 'rx_core/rx_string.dart'; |
15 | - | ||
16 | part 'rx_iterables/rx_list.dart'; | 15 | part 'rx_iterables/rx_list.dart'; |
17 | -part 'rx_iterables/rx_set.dart'; | ||
18 | part 'rx_iterables/rx_map.dart'; | 16 | part 'rx_iterables/rx_map.dart'; |
17 | +part 'rx_iterables/rx_set.dart'; |
@@ -2,12 +2,11 @@ import 'dart:async'; | @@ -2,12 +2,11 @@ import 'dart:async'; | ||
2 | 2 | ||
3 | import 'package:flutter/foundation.dart'; | 3 | import 'package:flutter/foundation.dart'; |
4 | import 'package:flutter/widgets.dart'; | 4 | import 'package:flutter/widgets.dart'; |
5 | -import 'package:get/get_instance/src/lifecycle.dart'; | ||
6 | 5 | ||
7 | import '../../../get_core/get_core.dart'; | 6 | import '../../../get_core/get_core.dart'; |
8 | import '../../../get_instance/src/get_instance.dart'; | 7 | import '../../../get_instance/src/get_instance.dart'; |
8 | +import '../../../get_instance/src/lifecycle.dart'; | ||
9 | import '../../../get_rx/src/rx_types/rx_types.dart'; | 9 | import '../../../get_rx/src/rx_types/rx_types.dart'; |
10 | -import '../../get_state_manager.dart'; | ||
11 | 10 | ||
12 | typedef GetXControllerBuilder<T extends GetLifeCycleMixin> = Widget Function( | 11 | typedef GetXControllerBuilder<T extends GetLifeCycleMixin> = Widget Function( |
13 | T controller); | 12 | T controller); |
@@ -35,7 +35,7 @@ class _ObxState extends State<ObxWidget> { | @@ -35,7 +35,7 @@ class _ObxState extends State<ObxWidget> { | ||
35 | @override | 35 | @override |
36 | void initState() { | 36 | void initState() { |
37 | super.initState(); | 37 | super.initState(); |
38 | - subs = _observer.listen(_updateTree, cancelOnError: false); | 38 | + subs = _observer.subject.stream.listen(_updateTree, cancelOnError: false); |
39 | } | 39 | } |
40 | 40 | ||
41 | void _updateTree(_) { | 41 | void _updateTree(_) { |
@@ -361,20 +361,8 @@ class BindWrapper<T> extends InheritedWidget { | @@ -361,20 +361,8 @@ class BindWrapper<T> extends InheritedWidget { | ||
361 | this.didUpdateWidget, | 361 | this.didUpdateWidget, |
362 | }) : super(key: key, child: child); | 362 | }) : super(key: key, child: child); |
363 | 363 | ||
364 | - /// The [Listenable] object to which to listen. | ||
365 | - /// | ||
366 | - /// Whenever this object sends change notifications, the dependents of this | ||
367 | - /// widget are triggered. | ||
368 | - /// | ||
369 | - /// By default, whenever the [controller] is changed (including when changing to | ||
370 | - /// or from null), if the old controller is not equal to the new controller (as | ||
371 | - /// determined by the `==` operator), notifications are sent. This behavior | ||
372 | - /// can be overridden by overriding [updateShouldNotify]. | ||
373 | - /// | ||
374 | - /// While the [controller] is null, no notifications are sent, since the null | ||
375 | - /// object cannot itself send notifications. | ||
376 | - final InitBuilder<T>? init; | ||
377 | 364 | ||
365 | + final InitBuilder<T>? init; | ||
378 | final bool global; | 366 | final bool global; |
379 | final Object? id; | 367 | final Object? id; |
380 | final String? tag; | 368 | final String? tag; |
@@ -411,7 +399,6 @@ class BindElement<T> extends InheritedElement { | @@ -411,7 +399,6 @@ class BindElement<T> extends InheritedElement { | ||
411 | T? _controller; | 399 | T? _controller; |
412 | 400 | ||
413 | T get controller { | 401 | T get controller { |
414 | - print('get controller $T'); | ||
415 | if (_controller == null) { | 402 | if (_controller == null) { |
416 | _controller = _controllerBuilder?.call(); | 403 | _controller = _controllerBuilder?.call(); |
417 | _subscribeToController(); | 404 | _subscribeToController(); |
@@ -583,6 +570,7 @@ class BindError<T> extends Error { | @@ -583,6 +570,7 @@ class BindError<T> extends Error { | ||
583 | /// instance of Bindings to manage the | 570 | /// instance of Bindings to manage the |
584 | /// dependencies() (via Get.put()) for the Route you are opening. | 571 | /// dependencies() (via Get.put()) for the Route you are opening. |
585 | // ignore: one_member_abstracts | 572 | // ignore: one_member_abstracts |
586 | -abstract class Binding { | 573 | +abstract class Binding extends BindingsInterface<List<Bind>> { |
574 | + @override | ||
587 | List<Bind> dependencies(); | 575 | List<Bind> dependencies(); |
588 | } | 576 | } |
@@ -11,14 +11,7 @@ typedef GetStateUpdate = void Function(); | @@ -11,14 +11,7 @@ typedef GetStateUpdate = void Function(); | ||
11 | 11 | ||
12 | class ListNotifier extends Listenable with ListNotifierMixin {} | 12 | class ListNotifier extends Listenable with ListNotifierMixin {} |
13 | 13 | ||
14 | -//mixin ListenableMixin implements Listenable {} | ||
15 | mixin ListNotifierMixin on Listenable { | 14 | mixin ListNotifierMixin on Listenable { |
16 | - // int _version = 0; | ||
17 | - // int _microtask = 0; | ||
18 | - | ||
19 | - // int get notifierVersion => _version; | ||
20 | - // int get notifierMicrotask => _microtask; | ||
21 | - | ||
22 | List<GetStateUpdate?>? _updaters = <GetStateUpdate?>[]; | 15 | List<GetStateUpdate?>? _updaters = <GetStateUpdate?>[]; |
23 | 16 | ||
24 | HashMap<Object?, List<GetStateUpdate>>? _updatersGroupIds = | 17 | HashMap<Object?, List<GetStateUpdate>>? _updatersGroupIds = |
@@ -28,16 +21,7 @@ mixin ListNotifierMixin on Listenable { | @@ -28,16 +21,7 @@ mixin ListNotifierMixin on Listenable { | ||
28 | void refresh() { | 21 | void refresh() { |
29 | assert(_debugAssertNotDisposed()); | 22 | assert(_debugAssertNotDisposed()); |
30 | 23 | ||
31 | - /// This debounce the call to update. | ||
32 | - /// It prevent errors and duplicates builds | ||
33 | - // if (_microtask == _version) { | ||
34 | - // _microtask++; | ||
35 | - // scheduleMicrotask(() { | ||
36 | - // _version++; | ||
37 | - // _microtask = _version; | ||
38 | _notifyUpdate(); | 24 | _notifyUpdate(); |
39 | - // }); | ||
40 | - // } | ||
41 | } | 25 | } |
42 | 26 | ||
43 | void _notifyUpdate() { | 27 | void _notifyUpdate() { |
@@ -58,17 +42,7 @@ mixin ListNotifierMixin on Listenable { | @@ -58,17 +42,7 @@ mixin ListNotifierMixin on Listenable { | ||
58 | @protected | 42 | @protected |
59 | void refreshGroup(Object id) { | 43 | void refreshGroup(Object id) { |
60 | assert(_debugAssertNotDisposed()); | 44 | assert(_debugAssertNotDisposed()); |
61 | - | ||
62 | - // /// This debounce the call to update. | ||
63 | - // /// It prevent errors and duplicates builds | ||
64 | - // if (_microtask == _version) { | ||
65 | - // _microtask++; | ||
66 | - // scheduleMicrotask(() { | ||
67 | - // _version++; | ||
68 | - // _microtask = _version; | ||
69 | _notifyIdUpdate(id); | 45 | _notifyIdUpdate(id); |
70 | - // }); | ||
71 | - // } | ||
72 | } | 46 | } |
73 | 47 | ||
74 | bool _debugAssertNotDisposed() { | 48 | bool _debugAssertNotDisposed() { |
@@ -147,7 +121,6 @@ class TaskManager { | @@ -147,7 +121,6 @@ class TaskManager { | ||
147 | static TaskManager get instance => _instance ??= TaskManager._(); | 121 | static TaskManager get instance => _instance ??= TaskManager._(); |
148 | 122 | ||
149 | GetStateUpdate? _setter; | 123 | GetStateUpdate? _setter; |
150 | - | ||
151 | List<VoidCallback>? _remove; | 124 | List<VoidCallback>? _remove; |
152 | 125 | ||
153 | void notify(List<GetStateUpdate?>? _updaters) { | 126 | void notify(List<GetStateUpdate?>? _updaters) { |
-
Please register or login to post a comment