Jonatas Borges

update to 4.1.2

  1 +## [4.1.2]
  2 +- Fix warning ˜can add data to a closed stream˜ when GetBuilder and Obx are nested
  3 +- Fix get_connect decoder can not be null (@Goddchen)
  4 +- Migrate example code (@3lB4rt0)
  5 +- Fix initial value of nullables (@RafaRuiz)
  6 +- Improve error message to navigation (@maxzod)
  7 +- Fix typo on docs (@Rahulshahare)
  8 +- Fixed darktheme being changed only through Get.changeTheme and not through the DarkTheme theme property in MaterialApp (@GoldenSoju)
  9 +- Fix controller is removed when navigate to same page (@eduardoflorence)
  10 +- Fix missing reload() and reloadAll() to Get extensions (@lkloon123)
  11 +
  12 +
1 ## [4.1.1] 13 ## [4.1.1]
2 -- default type to non nullables types 14 +- Remove mandatory initialValue to nullables types
3 15
4 ## [4.1.0] 16 ## [4.1.0]
5 - Added Rxn to non nullables reactives types 17 - Added Rxn to non nullables reactives types
@@ -119,7 +119,7 @@ void main() => runApp(GetMaterialApp(home: Home())); @@ -119,7 +119,7 @@ void main() => runApp(GetMaterialApp(home: Home()));
119 ``` 119 ```
120 120
121 - 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. 121 - 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.
122 -- Note²: This step in only necessary if you gonna use route management (`Get.to()`, `Get.back()` and so on). If you not gonna use it then it is not necessary to do step 1 122 +- Note²: This step is only necessary if you gonna use route management (`Get.to()`, `Get.back()` and so on). If you not gonna use it then it is not necessary to do step 1
123 123
124 - Step 2: 124 - Step 2:
125 Create your business logic class and place all variables, methods and controllers inside it. 125 Create your business logic class and place all variables, methods and controllers inside it.
@@ -282,6 +282,7 @@ As the view has only widgets, you can use a view for android, and another for iO @@ -282,6 +282,7 @@ As the view has only widgets, you can use a view for android, and another for iO
282 However, some examples like internationalization, Snackbars without context, validators, responsiveness and other Getx resources, were not explored (and it would not even be possible to explore all resources in such a simple example), so below is an example not very complete, but trying demonstrate how to use internationalization, reactive custom classes, reactive lists, snackbars contextless, workers etc. 282 However, some examples like internationalization, Snackbars without context, validators, responsiveness and other Getx resources, were not explored (and it would not even be possible to explore all resources in such a simple example), so below is an example not very complete, but trying demonstrate how to use internationalization, reactive custom classes, reactive lists, snackbars contextless, workers etc.
283 283
284 ```dart 284 ```dart
  285 +import 'dart:ui';
285 import 'package:flutter/material.dart'; 286 import 'package:flutter/material.dart';
286 import 'package:get/get.dart'; 287 import 'package:get/get.dart';
287 288
@@ -397,29 +398,27 @@ class Second extends GetView<ControllerX> { @@ -397,29 +398,27 @@ class Second extends GetView<ControllerX> {
397 child: Column( 398 child: Column(
398 mainAxisAlignment: MainAxisAlignment.center, 399 mainAxisAlignment: MainAxisAlignment.center,
399 children: [ 400 children: [
400 - GetX<ControllerX>(  
401 - // Using bindings you don't need of init: method  
402 - // Using Getx you can take controller instance of "builder: (_)"  
403 - builder: (_) { 401 + Obx(
  402 + () {
404 print("count1 rebuild"); 403 print("count1 rebuild");
405 - return Text('${_.count1}'); 404 + return Text('${controller.count1}');
406 }, 405 },
407 ), 406 ),
408 - GetX<ControllerX>(  
409 - builder: (_) { 407 + Obx(
  408 + () {
410 print("count2 rebuild"); 409 print("count2 rebuild");
411 return Text('${controller.count2}'); 410 return Text('${controller.count2}');
412 }, 411 },
413 ), 412 ),
414 - GetX<ControllerX>(builder: (_) { 413 + Obx(() {
415 print("sum rebuild"); 414 print("sum rebuild");
416 - return Text('${_.sum}'); 415 + return Text('${controller.sum}');
417 }), 416 }),
418 - GetX<ControllerX>(  
419 - builder: (_) => Text('Name: ${controller.user.value.name}'), 417 + Obx(
  418 + () => Text('Name: ${controller.user.value?.name}'),
420 ), 419 ),
421 - GetX<ControllerX>(  
422 - builder: (_) => Text('Age: ${_.user.value.age}'), 420 + Obx(
  421 + () => Text('Age: ${controller.user.value?.age}'),
423 ), 422 ),
424 ElevatedButton( 423 ElevatedButton(
425 child: Text("Go to last page"), 424 child: Text("Go to last page"),
@@ -440,25 +439,25 @@ class Second extends GetView<ControllerX> { @@ -440,25 +439,25 @@ class Second extends GetView<ControllerX> {
440 ElevatedButton( 439 ElevatedButton(
441 child: Text("Increment"), 440 child: Text("Increment"),
442 onPressed: () { 441 onPressed: () {
443 - Get.find<ControllerX>().increment(); 442 + controller.increment();
444 }, 443 },
445 ), 444 ),
446 ElevatedButton( 445 ElevatedButton(
447 child: Text("Increment"), 446 child: Text("Increment"),
448 onPressed: () { 447 onPressed: () {
449 - Get.find<ControllerX>().increment2(); 448 + controller.increment2();
450 }, 449 },
451 ), 450 ),
452 ElevatedButton( 451 ElevatedButton(
453 child: Text("Update name"), 452 child: Text("Update name"),
454 onPressed: () { 453 onPressed: () {
455 - Get.find<ControllerX>().updateUser(); 454 + controller.updateUser();
456 }, 455 },
457 ), 456 ),
458 ElevatedButton( 457 ElevatedButton(
459 child: Text("Dispose worker"), 458 child: Text("Dispose worker"),
460 onPressed: () { 459 onPressed: () {
461 - Get.find<ControllerX>().disposeWorker(); 460 + controller.disposeWorker();
462 }, 461 },
463 ), 462 ),
464 ], 463 ],
@@ -509,7 +508,7 @@ class ControllerX extends GetxController { @@ -509,7 +508,7 @@ class ControllerX extends GetxController {
509 508
510 updateUser() { 509 updateUser() {
511 user.update((value) { 510 user.update((value) {
512 - value.name = 'Jose'; 511 + value!.name = 'Jose';
513 value.age = 30; 512 value.age = 30;
514 }); 513 });
515 } 514 }
@@ -523,7 +522,7 @@ class ControllerX extends GetxController { @@ -523,7 +522,7 @@ class ControllerX extends GetxController {
523 /// Here is an outline of how you can use them: 522 /// Here is an outline of how you can use them:
524 523
525 /// made this if you need cancel you worker 524 /// made this if you need cancel you worker
526 - Worker _ever; 525 + late Worker _ever;
527 526
528 @override 527 @override
529 onInit() { 528 onInit() {
@@ -562,8 +561,8 @@ class SizeTransitions extends CustomTransition { @@ -562,8 +561,8 @@ class SizeTransitions extends CustomTransition {
562 @override 561 @override
563 Widget buildTransition( 562 Widget buildTransition(
564 BuildContext context, 563 BuildContext context,
565 - Curve curve,  
566 - Alignment alignment, 564 + Curve? curve,
  565 + Alignment? alignment,
567 Animation<double> animation, 566 Animation<double> animation,
568 Animation<double> secondaryAnimation, 567 Animation<double> secondaryAnimation,
569 Widget child) { 568 Widget child) {
@@ -572,7 +571,7 @@ class SizeTransitions extends CustomTransition { @@ -572,7 +571,7 @@ class SizeTransitions extends CustomTransition {
572 child: SizeTransition( 571 child: SizeTransition(
573 sizeFactor: CurvedAnimation( 572 sizeFactor: CurvedAnimation(
574 parent: animation, 573 parent: animation,
575 - curve: curve, 574 + curve: curve!,
576 ), 575 ),
577 child: child, 576 child: child,
578 ), 577 ),
@@ -18,7 +18,6 @@ class CountryView extends GetView<HomeController> { @@ -18,7 +18,6 @@ class CountryView extends GetView<HomeController> {
18 child: BackdropFilter( 18 child: BackdropFilter(
19 filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0), 19 filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0),
20 child: Container( 20 child: Container(
21 - decoration: BoxDecoration(color: Colors.white.withOpacity(0.0)),  
22 child: Scaffold( 21 child: Scaffold(
23 backgroundColor: Colors.transparent, 22 backgroundColor: Colors.transparent,
24 appBar: AppBar( 23 appBar: AppBar(
@@ -21,7 +21,6 @@ class DetailsView extends StatelessWidget { @@ -21,7 +21,6 @@ class DetailsView extends StatelessWidget {
21 child: BackdropFilter( 21 child: BackdropFilter(
22 filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0), 22 filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0),
23 child: Container( 23 child: Container(
24 - decoration: BoxDecoration(color: Colors.white.withOpacity(0.0)),  
25 child: Scaffold( 24 child: Scaffold(
26 backgroundColor: Colors.transparent, 25 backgroundColor: Colors.transparent,
27 appBar: AppBar( 26 appBar: AppBar(
@@ -249,7 +249,7 @@ class GetHttpClient { @@ -249,7 +249,7 @@ class GetHttpClient {
249 method: 'get', 249 method: 'get',
250 url: uri, 250 url: uri,
251 headers: headers, 251 headers: headers,
252 - decoder: decoder ?? (defaultDecoder as Decoder<T>), 252 + decoder: decoder ?? (defaultDecoder as Decoder<T>?),
253 contentLength: 0, 253 contentLength: 0,
254 )); 254 ));
255 } 255 }
@@ -107,6 +107,11 @@ extension Inst on GetInterface { @@ -107,6 +107,11 @@ extension Inst on GetInterface {
107 Future<bool> delete<S>({String? tag, bool force = false}) async => 107 Future<bool> delete<S>({String? tag, bool force = false}) async =>
108 GetInstance().delete<S>(tag: tag, force: force); 108 GetInstance().delete<S>(tag: tag, force: force);
109 109
  110 + void reloadAll({bool force = false}) => GetInstance().reloadAll(force: force);
  111 +
  112 + void reload<S>({String? tag, String? key, bool force = false}) =>
  113 + GetInstance().reload<S>(tag: tag, key: key, force: force);
  114 +
110 /// Checks if a Class Instance<[S]> (or [tag]) is registered in memory. 115 /// Checks if a Class Instance<[S]> (or [tag]) is registered in memory.
111 /// - [tag] optional, if you use a [tag] to register the Instance. 116 /// - [tag] optional, if you use a [tag] to register the Instance.
112 bool isRegistered<S>({String? tag}) => 117 bool isRegistered<S>({String? tag}) =>
@@ -345,7 +345,6 @@ extension ExtensionDialog on GetInterface { @@ -345,7 +345,6 @@ extension ExtensionDialog on GetInterface {
345 actions.add(TextButton( 345 actions.add(TextButton(
346 style: TextButton.styleFrom( 346 style: TextButton.styleFrom(
347 tapTargetSize: MaterialTapTargetSize.shrinkWrap, 347 tapTargetSize: MaterialTapTargetSize.shrinkWrap,
348 - //color: buttonColor ?? theme.accentColor,  
349 backgroundColor: buttonColor ?? theme.accentColor, 348 backgroundColor: buttonColor ?? theme.accentColor,
350 shape: RoundedRectangleBorder( 349 shape: RoundedRectangleBorder(
351 borderRadius: BorderRadius.circular(100)), 350 borderRadius: BorderRadius.circular(100)),
@@ -364,6 +363,7 @@ extension ExtensionDialog on GetInterface { @@ -364,6 +363,7 @@ extension ExtensionDialog on GetInterface {
364 Widget baseAlertDialog = AlertDialog( 363 Widget baseAlertDialog = AlertDialog(
365 titlePadding: EdgeInsets.all(8), 364 titlePadding: EdgeInsets.all(8),
366 contentPadding: EdgeInsets.all(8), 365 contentPadding: EdgeInsets.all(8),
  366 +
367 backgroundColor: backgroundColor ?? theme.dialogBackgroundColor, 367 backgroundColor: backgroundColor ?? theme.dialogBackgroundColor,
368 shape: RoundedRectangleBorder( 368 shape: RoundedRectangleBorder(
369 borderRadius: BorderRadius.all(Radius.circular(radius))), 369 borderRadius: BorderRadius.all(Radius.circular(radius))),
@@ -434,8 +434,10 @@ extension ExtensionBottomSheet on GetInterface { @@ -434,8 +434,10 @@ extension ExtensionBottomSheet on GetInterface {
434 // theme: Theme.of(key.currentContext, shadowThemeOnly: true), 434 // theme: Theme.of(key.currentContext, shadowThemeOnly: true),
435 theme: Theme.of(key.currentContext!), 435 theme: Theme.of(key.currentContext!),
436 isScrollControlled: isScrollControlled, 436 isScrollControlled: isScrollControlled,
  437 +
437 barrierLabel: MaterialLocalizations.of(key.currentContext!) 438 barrierLabel: MaterialLocalizations.of(key.currentContext!)
438 .modalBarrierDismissLabel, 439 .modalBarrierDismissLabel,
  440 +
439 backgroundColor: backgroundColor ?? Colors.transparent, 441 backgroundColor: backgroundColor ?? Colors.transparent,
440 elevation: elevation, 442 elevation: elevation,
441 shape: shape, 443 shape: shape,
@@ -519,6 +521,9 @@ extension GetNavigation on GetInterface { @@ -519,6 +521,9 @@ extension GetNavigation on GetInterface {
519 Using a widget function instead of a widget fully guarantees that the widget and its controllers will be removed from memory when they are no longer used. 521 Using a widget function instead of a widget fully guarantees that the widget and its controllers will be removed from memory when they are no longer used.
520 '''); 522 ''');
521 return () => page; 523 return () => page;
  524 + } else if (page is String) {
  525 + throw '''Unexpected String,
  526 +use toNamed() instead''';
522 } else { 527 } else {
523 throw '''Unexpected format, 528 throw '''Unexpected format,
524 you can only use widgets and widget functions here'''; 529 you can only use widgets and widget functions here''';
@@ -245,7 +245,7 @@ class GetMaterialApp extends StatelessWidget { @@ -245,7 +245,7 @@ class GetMaterialApp extends StatelessWidget {
245 onGenerateTitle: onGenerateTitle, 245 onGenerateTitle: onGenerateTitle,
246 color: color, 246 color: color,
247 theme: _.theme ?? theme ?? ThemeData.fallback(), 247 theme: _.theme ?? theme ?? ThemeData.fallback(),
248 - darkTheme: darkTheme, 248 + darkTheme: _.darkTheme ?? darkTheme ?? ThemeData.fallback(),
249 themeMode: _.themeMode ?? themeMode, 249 themeMode: _.themeMode ?? themeMode,
250 locale: Get.locale ?? locale, 250 locale: Get.locale ?? locale,
251 localizationsDelegates: localizationsDelegates, 251 localizationsDelegates: localizationsDelegates,
@@ -293,7 +293,7 @@ class GetMaterialApp extends StatelessWidget { @@ -293,7 +293,7 @@ class GetMaterialApp extends StatelessWidget {
293 onGenerateTitle: onGenerateTitle, 293 onGenerateTitle: onGenerateTitle,
294 color: color, 294 color: color,
295 theme: _.theme ?? theme ?? ThemeData.fallback(), 295 theme: _.theme ?? theme ?? ThemeData.fallback(),
296 - darkTheme: darkTheme, 296 + darkTheme: _.darkTheme ?? darkTheme ?? ThemeData.fallback(),
297 themeMode: _.themeMode ?? themeMode, 297 themeMode: _.themeMode ?? themeMode,
298 locale: Get.locale ?? locale, 298 locale: Get.locale ?? locale,
299 localizationsDelegates: localizationsDelegates, 299 localizationsDelegates: localizationsDelegates,
@@ -10,6 +10,7 @@ class GetMaterialController extends GetxController { @@ -10,6 +10,7 @@ class GetMaterialController extends GetxController {
10 bool testMode = false; 10 bool testMode = false;
11 Key? unikey; 11 Key? unikey;
12 ThemeData? theme; 12 ThemeData? theme;
  13 + ThemeData? darkTheme;
13 ThemeMode? themeMode; 14 ThemeMode? themeMode;
14 15
15 bool defaultPopGesture = GetPlatform.isIOS; 16 bool defaultPopGesture = GetPlatform.isIOS;
@@ -36,7 +37,15 @@ class GetMaterialController extends GetxController { @@ -36,7 +37,15 @@ class GetMaterialController extends GetxController {
36 Map<dynamic, GlobalKey<NavigatorState>> keys = {}; 37 Map<dynamic, GlobalKey<NavigatorState>> keys = {};
37 38
38 void setTheme(ThemeData value) { 39 void setTheme(ThemeData value) {
39 - theme = value; 40 + if (darkTheme == null) {
  41 + theme = value;
  42 + } else {
  43 + if (value.brightness == Brightness.light) {
  44 + theme = value;
  45 + } else {
  46 + darkTheme = value;
  47 + }
  48 + }
40 update(); 49 update();
41 } 50 }
42 51
@@ -31,7 +31,7 @@ class GetPageRoute<T> extends PageRoute<T> { @@ -31,7 +31,7 @@ class GetPageRoute<T> extends PageRoute<T> {
31 this.maintainState = true, 31 this.maintainState = true,
32 bool fullscreenDialog = false, 32 bool fullscreenDialog = false,
33 this.middlewares, 33 this.middlewares,
34 - }) : reference = "$routeName: ${page.hashCode}", 34 + }) : reference = "$routeName: ${settings?.hashCode ?? page.hashCode}",
35 super(settings: settings, fullscreenDialog: fullscreenDialog); 35 super(settings: settings, fullscreenDialog: fullscreenDialog);
36 36
37 @override 37 @override
@@ -161,7 +161,7 @@ class GetObserver extends NavigatorObserver { @@ -161,7 +161,7 @@ class GetObserver extends NavigatorObserver {
161 value.isDialog = newRoute.isDialog; 161 value.isDialog = newRoute.isDialog;
162 }); 162 });
163 163
164 - print('currentRoute.isDialog ${currentRoute.isDialog}'); 164 + // print('currentRoute.isDialog ${currentRoute.isDialog}');
165 165
166 routing?.call(_routeSend); 166 routing?.call(_routeSend);
167 } 167 }
@@ -187,6 +187,7 @@ class PageRedirect { @@ -187,6 +187,7 @@ class PageRedirect {
187 ) 187 )
188 : GetPageRoute<T>( 188 : GetPageRoute<T>(
189 page: route!.page, 189 page: route!.page,
  190 + routeName: route!.name,
190 parameter: route!.parameter, 191 parameter: route!.parameter,
191 settings: RouteSettings( 192 settings: RouteSettings(
192 name: settings.name, arguments: settings.arguments), 193 name: settings.name, arguments: settings.arguments),
@@ -136,7 +136,9 @@ mixin NotifyManager<T> { @@ -136,7 +136,9 @@ mixin NotifyManager<T> {
136 /// Subscribe to changes on the inner stream. 136 /// Subscribe to changes on the inner stream.
137 void addListener(GetStream<T> rxGetx) { 137 void addListener(GetStream<T> rxGetx) {
138 if (!_subscriptions.containsKey(rxGetx)) { 138 if (!_subscriptions.containsKey(rxGetx)) {
139 - final subs = rxGetx.listen(subject.add); 139 + final subs = rxGetx.listen((data) {
  140 + if (!subject.isClosed) subject.add(data);
  141 + });
140 final listSubscriptions = 142 final listSubscriptions =
141 _subscriptions[rxGetx] ??= <StreamSubscription>[]; 143 _subscriptions[rxGetx] ??= <StreamSubscription>[];
142 listSubscriptions.add(subs); 144 listSubscriptions.add(subs);
@@ -149,8 +151,12 @@ mixin NotifyManager<T> { @@ -149,8 +151,12 @@ mixin NotifyManager<T> {
149 void Function()? onDone, 151 void Function()? onDone,
150 bool? cancelOnError, 152 bool? cancelOnError,
151 }) => 153 }) =>
152 - subject.listen(onData,  
153 - onError: onError, onDone: onDone, cancelOnError: cancelOnError); 154 + subject.listen(
  155 + onData,
  156 + onError: onError,
  157 + onDone: onDone,
  158 + cancelOnError: cancelOnError ?? false,
  159 + );
154 160
155 /// Closes the subscriptions for this Rx, releasing the resources. 161 /// Closes the subscriptions for this Rx, releasing the resources.
156 void close() { 162 void close() {
@@ -18,8 +18,10 @@ class GetX<T extends DisposableInterface> extends StatefulWidget { @@ -18,8 +18,10 @@ class GetX<T extends DisposableInterface> extends StatefulWidget {
18 // final StreamController Function(T) streamController; 18 // final StreamController Function(T) streamController;
19 final bool autoRemove; 19 final bool autoRemove;
20 final bool assignId; 20 final bool assignId;
21 - final void Function(State state)? initState, dispose, didChangeDependencies;  
22 - final void Function(GetX oldWidget, State state)? didUpdateWidget; 21 + final void Function(GetXState<T> state)? initState,
  22 + dispose,
  23 + didChangeDependencies;
  24 + final void Function(GetX oldWidget, GetXState<T> state)? didUpdateWidget;
23 final T? init; 25 final T? init;
24 final String? tag; 26 final String? tag;
25 27
@@ -48,8 +50,8 @@ class GetXState<T extends DisposableInterface> extends State<GetX<T>> { @@ -48,8 +50,8 @@ class GetXState<T extends DisposableInterface> extends State<GetX<T>> {
48 } 50 }
49 RxInterface? _observer; 51 RxInterface? _observer;
50 T? controller; 52 T? controller;
51 - bool? isCreator = false;  
52 - late StreamSubscription subs; 53 + bool? _isCreator = false;
  54 + late StreamSubscription _subs;
53 55
54 @override 56 @override
55 void initState() { 57 void initState() {
@@ -59,26 +61,26 @@ class GetXState<T extends DisposableInterface> extends State<GetX<T>> { @@ -59,26 +61,26 @@ class GetXState<T extends DisposableInterface> extends State<GetX<T>> {
59 if (widget.global) { 61 if (widget.global) {
60 if (isRegistered) { 62 if (isRegistered) {
61 if (GetInstance().isPrepared<T>(tag: widget.tag)) { 63 if (GetInstance().isPrepared<T>(tag: widget.tag)) {
62 - isCreator = true; 64 + _isCreator = true;
63 } else { 65 } else {
64 - isCreator = false; 66 + _isCreator = false;
65 } 67 }
66 controller = GetInstance().find<T>(tag: widget.tag); 68 controller = GetInstance().find<T>(tag: widget.tag);
67 } else { 69 } else {
68 controller = widget.init; 70 controller = widget.init;
69 - isCreator = true; 71 + _isCreator = true;
70 GetInstance().put<T>(controller!, tag: widget.tag); 72 GetInstance().put<T>(controller!, tag: widget.tag);
71 } 73 }
72 } else { 74 } else {
73 controller = widget.init; 75 controller = widget.init;
74 - isCreator = true; 76 + _isCreator = true;
75 controller?.onStart(); 77 controller?.onStart();
76 } 78 }
77 widget.initState?.call(this); 79 widget.initState?.call(this);
78 if (widget.global && Get.smartManagement == SmartManagement.onlyBuilder) { 80 if (widget.global && Get.smartManagement == SmartManagement.onlyBuilder) {
79 controller?.onStart(); 81 controller?.onStart();
80 } 82 }
81 - subs = _observer!.listen((data) => setState(() {})); 83 + _subs = _observer!.listen((data) => setState(() {}), cancelOnError: false);
82 super.initState(); 84 super.initState();
83 } 85 }
84 86
@@ -99,15 +101,15 @@ class GetXState<T extends DisposableInterface> extends State<GetX<T>> { @@ -99,15 +101,15 @@ class GetXState<T extends DisposableInterface> extends State<GetX<T>> {
99 @override 101 @override
100 void dispose() { 102 void dispose() {
101 if (widget.dispose != null) widget.dispose!(this); 103 if (widget.dispose != null) widget.dispose!(this);
102 - if (isCreator! || widget.assignId) { 104 + if (_isCreator! || widget.assignId) {
103 if (widget.autoRemove && GetInstance().isRegistered<T>(tag: widget.tag)) { 105 if (widget.autoRemove && GetInstance().isRegistered<T>(tag: widget.tag)) {
104 GetInstance().delete<T>(tag: widget.tag); 106 GetInstance().delete<T>(tag: widget.tag);
105 } 107 }
106 } 108 }
107 - subs.cancel(); 109 + _subs.cancel();
108 _observer!.close(); 110 _observer!.close();
109 controller = null; 111 controller = null;
110 - isCreator = null; 112 + _isCreator = null;
111 super.dispose(); 113 super.dispose();
112 } 114 }
113 115
@@ -29,7 +29,7 @@ class _ObxState extends State<ObxWidget> { @@ -29,7 +29,7 @@ class _ObxState extends State<ObxWidget> {
29 29
30 @override 30 @override
31 void initState() { 31 void initState() {
32 - subs = _observer!.listen(_updateTree); 32 + subs = _observer!.listen(_updateTree, cancelOnError: false);
33 super.initState(); 33 super.initState();
34 } 34 }
35 35
@@ -59,8 +59,11 @@ class GetBuilder<T extends GetxController> extends StatefulWidget { @@ -59,8 +59,11 @@ class GetBuilder<T extends GetxController> extends StatefulWidget {
59 final bool autoRemove; 59 final bool autoRemove;
60 final bool assignId; 60 final bool assignId;
61 final Object Function(T value)? filter; 61 final Object Function(T value)? filter;
62 - final void Function(State state)? initState, dispose, didChangeDependencies;  
63 - final void Function(GetBuilder oldWidget, State state)? didUpdateWidget; 62 + final void Function(GetBuilderState<T> state)? initState,
  63 + dispose,
  64 + didChangeDependencies;
  65 + final void Function(GetBuilder oldWidget, GetBuilderState<T> state)?
  66 + didUpdateWidget;
64 final T? init; 67 final T? init;
65 68
66 const GetBuilder({ 69 const GetBuilder({
@@ -99,22 +102,15 @@ class GetBuilder<T extends GetxController> extends StatefulWidget { @@ -99,22 +102,15 @@ class GetBuilder<T extends GetxController> extends StatefulWidget {
99 // } 102 // }
100 103
101 @override 104 @override
102 - _GetBuilderState<T> createState() => _GetBuilderState<T>(); 105 + GetBuilderState<T> createState() => GetBuilderState<T>();
103 } 106 }
104 107
105 -class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>> 108 +class GetBuilderState<T extends GetxController> extends State<GetBuilder<T>>
106 with GetStateUpdaterMixin { 109 with GetStateUpdaterMixin {
107 T? controller; 110 T? controller;
108 - bool? isCreator = false;  
109 - VoidCallback? remove; 111 + bool? _isCreator = false;
  112 + VoidCallback? _remove;
110 Object? _filter; 113 Object? _filter;
111 - List<VoidCallback>? _watchs;  
112 -  
113 - // static _GetBuilderState _currentState;  
114 -  
115 - void watch(VoidCallback listener) {  
116 - (_watchs ??= <VoidCallback>[]).add(listener);  
117 - }  
118 114
119 @override 115 @override
120 void initState() { 116 void initState() {
@@ -127,19 +123,19 @@ class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>> @@ -127,19 +123,19 @@ class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>>
127 if (widget.global) { 123 if (widget.global) {
128 if (isRegistered) { 124 if (isRegistered) {
129 if (GetInstance().isPrepared<T>(tag: widget.tag)) { 125 if (GetInstance().isPrepared<T>(tag: widget.tag)) {
130 - isCreator = true; 126 + _isCreator = true;
131 } else { 127 } else {
132 - isCreator = false; 128 + _isCreator = false;
133 } 129 }
134 controller = GetInstance().find<T>(tag: widget.tag); 130 controller = GetInstance().find<T>(tag: widget.tag);
135 } else { 131 } else {
136 controller = widget.init; 132 controller = widget.init;
137 - isCreator = true; 133 + _isCreator = true;
138 GetInstance().put<T>(controller!, tag: widget.tag); 134 GetInstance().put<T>(controller!, tag: widget.tag);
139 } 135 }
140 } else { 136 } else {
141 controller = widget.init; 137 controller = widget.init;
142 - isCreator = true; 138 + _isCreator = true;
143 controller?.onStart(); 139 controller?.onStart();
144 } 140 }
145 141
@@ -154,8 +150,8 @@ class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>> @@ -154,8 +150,8 @@ class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>>
154 /// It gets a reference to the remove() callback, to delete the 150 /// It gets a reference to the remove() callback, to delete the
155 /// setState "link" from the Controller. 151 /// setState "link" from the Controller.
156 void _subscribeToController() { 152 void _subscribeToController() {
157 - remove?.call();  
158 - remove = (widget.id == null) 153 + _remove?.call();
  154 + _remove = (widget.id == null)
159 ? controller?.addListener( 155 ? controller?.addListener(
160 _filter != null ? _filterUpdate : getUpdate, 156 _filter != null ? _filterUpdate : getUpdate,
161 ) 157 )
@@ -177,19 +173,18 @@ class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>> @@ -177,19 +173,18 @@ class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>>
177 void dispose() { 173 void dispose() {
178 super.dispose(); 174 super.dispose();
179 widget.dispose?.call(this); 175 widget.dispose?.call(this);
180 - if (isCreator! || widget.assignId) { 176 + if (_isCreator! || widget.assignId) {
181 if (widget.autoRemove && GetInstance().isRegistered<T>(tag: widget.tag)) { 177 if (widget.autoRemove && GetInstance().isRegistered<T>(tag: widget.tag)) {
182 GetInstance().delete<T>(tag: widget.tag); 178 GetInstance().delete<T>(tag: widget.tag);
183 } 179 }
184 } 180 }
185 181
186 - remove?.call(); 182 + _remove?.call();
187 183
188 controller = null; 184 controller = null;
189 - isCreator = null;  
190 - remove = null; 185 + _isCreator = null;
  186 + _remove = null;
191 _filter = null; 187 _filter = null;
192 - _watchs = null;  
193 } 188 }
194 189
195 @override 190 @override
1 -import 'dart:async';  
2 import 'dart:collection'; 1 import 'dart:collection';
3 import 'package:flutter/foundation.dart'; 2 import 'package:flutter/foundation.dart';
4 import 'package:flutter/widgets.dart'; 3 import 'package:flutter/widgets.dart';
@@ -11,11 +10,11 @@ typedef Disposer = void Function(); @@ -11,11 +10,11 @@ typedef Disposer = void Function();
11 typedef GetStateUpdate = void Function(); 10 typedef GetStateUpdate = void Function();
12 11
13 class ListNotifier implements Listenable { 12 class ListNotifier implements Listenable {
14 - int _version = 0;  
15 - int _microtask = 0; 13 + // int _version = 0;
  14 + // int _microtask = 0;
16 15
17 - int get notifierVersion => _version;  
18 - int get notifierMicrotask => _microtask; 16 + // int get notifierVersion => _version;
  17 + // int get notifierMicrotask => _microtask;
19 18
20 List<GetStateUpdate?>? _updaters = <GetStateUpdate?>[]; 19 List<GetStateUpdate?>? _updaters = <GetStateUpdate?>[];
21 20
@@ -28,14 +27,14 @@ class ListNotifier implements Listenable { @@ -28,14 +27,14 @@ class ListNotifier implements Listenable {
28 27
29 /// This debounce the call to update. 28 /// This debounce the call to update.
30 /// It prevent errors and duplicates builds 29 /// It prevent errors and duplicates builds
31 - if (_microtask == _version) {  
32 - _microtask++;  
33 - scheduleMicrotask(() {  
34 - _version++;  
35 - _microtask = _version;  
36 - _notifyUpdate();  
37 - });  
38 - } 30 + // if (_microtask == _version) {
  31 + // _microtask++;
  32 + // scheduleMicrotask(() {
  33 + // _version++;
  34 + // _microtask = _version;
  35 + _notifyUpdate();
  36 + // });
  37 + // }
39 } 38 }
40 39
41 void _notifyUpdate() { 40 void _notifyUpdate() {
@@ -149,7 +149,7 @@ referenceValue is ${calculePercentage(referenceValue, requestedValue)}% more tha @@ -149,7 +149,7 @@ referenceValue is ${calculePercentage(referenceValue, requestedValue)}% more tha
149 print('GetValue delay $getx ms to made $times requests'); 149 print('GetValue delay $getx ms to made $times requests');
150 print('-----------'); 150 print('-----------');
151 print(''' 151 print('''
152 -GetValue is ${calculePercentage(dart, getx).round()}% more fast than Default ValueNotifier with $times requests'''); 152 +GetValue is ${calculePercentage(dart, getx).round()}% faster than Default ValueNotifier with $times requests''');
153 }); 153 });
154 154
155 test('run benchmarks from Streams', () async { 155 test('run benchmarks from Streams', () async {
@@ -162,7 +162,7 @@ GetValue is ${calculePercentage(dart, getx).round()}% more fast than Default Val @@ -162,7 +162,7 @@ GetValue is ${calculePercentage(dart, getx).round()}% more fast than Default Val
162 var dart = await stream(); 162 var dart = await stream();
163 print('-----------'); 163 print('-----------');
164 print(''' 164 print('''
165 -GetStream is ${calculePercentage(dart, mini).round()}% more fast than Default Stream with $times requests'''); 165 +GetStream is ${calculePercentage(dart, mini).round()}% faster than Default Stream with $times requests''');
166 print('-----------'); 166 print('-----------');
167 167
168 times = 30000; 168 times = 30000;
@@ -180,7 +180,7 @@ GetStream is ${calculePercentage(dart, mini).round()}% more fast than Default St @@ -180,7 +180,7 @@ GetStream is ${calculePercentage(dart, mini).round()}% more fast than Default St
180 print('getx_mini_stream delay $mini ms to made $times requests'); 180 print('getx_mini_stream delay $mini ms to made $times requests');
181 print('-----------'); 181 print('-----------');
182 print(''' 182 print('''
183 -GetStream is ${calculePercentage(dart, mini).round()}% more fast than Default Stream with $times requests'''); 183 +GetStream is ${calculePercentage(dart, mini).round()}% faster than Default Stream with $times requests''');
184 }); 184 });
185 } 185 }
186 186