Jonny Borges

fix multiples dependencies

## [4.3.6]
- Fix error with autodispose of additional dependencies beyond GetxController
- Added ability to add your own delegate to RouterOutlet (@steven-spiel)
## [4.3.5]
- Fix GetConnect timeout (@jasonlaw)
- Improve Vietnamese docs (@hp1909)
... ...
... ... @@ -7,7 +7,7 @@ import '../../get.dart';
class RouterReportManager<T> {
/// Holds a reference to `Get.reference` when the Instance was
/// created to manage the memory.
static final Map<Route?, String> _routesKey = {};
static final Map<Route?, List<String>> _routesKey = {};
/// Stores the onClose() references of instances created with `Get.create()`
/// using the `Get.reference`.
... ... @@ -29,7 +29,12 @@ class RouterReportManager<T> {
/// Links a Class instance [S] (or [tag]) to the current route.
/// Requires usage of `GetMaterialApp`.
static void reportDependencyLinkedToRoute(String depedencyKey) {
_routesKey[_current] = depedencyKey;
if (_current == null) return;
if (_routesKey.containsKey(_current)) {
_routesKey[_current!]!.add(depedencyKey);
} else {
_routesKey[_current] = <String>[depedencyKey];
}
}
static void clearRouteKeys() {
... ... @@ -46,9 +51,6 @@ class RouterReportManager<T> {
static void reportRouteDispose(Route disposed) {
if (Get.smartManagement != SmartManagement.onlyBuilder) {
WidgetsBinding.instance!.addPostFrameCallback((_) {
///TODO: Check if it's necessary to compare _current != disposed
///Adding it breaks the context Navigation logic,
///as it resolves by Route name.
_removeDependencyByRoute(disposed);
});
}
... ... @@ -56,11 +58,8 @@ class RouterReportManager<T> {
static void reportRouteWillDispose(Route disposed) {
final keysToRemove = <String>[];
_routesKey.forEach((key, value) {
if (key == disposed) {
keysToRemove.add(value);
}
});
_routesKey[disposed]?.forEach(keysToRemove.add);
/// Removes `Get.create()` instances registered in `routeName`.
if (_routesByCreate.containsKey(disposed)) {
... ... @@ -88,11 +87,8 @@ class RouterReportManager<T> {
/// Meant for internal usage of `GetPageRoute` and `GetDialogRoute`
static void _removeDependencyByRoute(Route routeName) {
final keysToRemove = <String>[];
_routesKey.forEach((key, value) {
if (key == routeName) {
keysToRemove.add(value);
}
});
_routesKey[routeName]?.forEach(keysToRemove.add);
/// Removes `Get.create()` instances registered in `routeName`.
if (_routesByCreate.containsKey(routeName)) {
... ... @@ -108,7 +104,7 @@ class RouterReportManager<T> {
for (final element in keysToRemove) {
final value = GetInstance().delete(key: element);
if (value) {
_routesKey.remove(element);
_routesKey[routeName]?.remove(element);
}
}
... ...
... ... @@ -7,7 +7,22 @@ import 'get_transition_mixin.dart';
import 'route_middleware.dart';
import 'transitions_type.dart';
class GetPageRoute<T> extends PageRoute<T> with GetPageRouteTransitionMixin<T> {
mixin PageRouteReportMixin<T> on Route<T> {
@override
void install() {
super.install();
RouterReportManager.reportCurrentRoute(this);
}
@override
void dispose() {
super.dispose();
RouterReportManager.reportRouteDispose(this);
}
}
class GetPageRoute<T> extends PageRoute<T>
with GetPageRouteTransitionMixin<T>, PageRouteReportMixin {
/// Creates a page route for use in an iOS designed app.
///
/// The [builder], [maintainState], and [fullscreenDialog] arguments must not
... ... @@ -35,11 +50,7 @@ class GetPageRoute<T> extends PageRoute<T> with GetPageRouteTransitionMixin<T> {
this.maintainState = true,
bool fullscreenDialog = false,
this.middlewares,
}) : super(settings: settings, fullscreenDialog: fullscreenDialog) {
_bla = this;
}
late Route _bla;
}) : super(settings: settings, fullscreenDialog: fullscreenDialog);
@override
final Duration transitionDuration;
... ... @@ -75,23 +86,8 @@ class GetPageRoute<T> extends PageRoute<T> with GetPageRouteTransitionMixin<T> {
final bool maintainState;
@override
void install() {
super.install();
RouterReportManager.reportCurrentRoute(this);
}
@override
void dispose() {
super.dispose();
if (_bla != this) {
throw 'DJHOSIDS';
}
RouterReportManager.reportRouteDispose(this);
// if (Get.smartManagement != SmartManagement.onlyBuilder) {
// GetInstance().removeDependencyByRoute("$reference");
// }
final middlewareRunner = MiddlewareRunner(middlewares);
middlewareRunner.runOnPageDispose();
}
... ...
name: get
description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX.
version: 4.3.5
version: 4.3.6
homepage: https://github.com/jonataslaw/getx
environment:
... ...