Jonny Borges

minor changes

... ... @@ -7,7 +7,7 @@ class ProductDetailsBinding extends Binding {
List<Bind> dependencies() {
return [
Bind.create<ProductDetailsController>(
() => ProductDetailsController(
(_) => ProductDetailsController(
Get.parameters['productId'] ?? '',
),
)
... ...
import 'dart:async';
import 'package:flutter/material.dart';
import '../../get_core/get_core.dart';
import '../../get_navigation/src/router_report.dart';
import 'lifecycle.dart';
... ... @@ -493,6 +495,10 @@ extension Inst on GetInterface {
typedef InstanceBuilderCallback<S> = S Function();
typedef InstanceCreateBuilderCallback<S> = S Function(BuildContext _);
// typedef InstanceBuilderCallback<S> = S Function();
// typedef InjectorBuilderCallback<S> = S Function(Inst);
typedef AsyncInstanceBuilderCallback<S> = Future<S> Function();
... ...
... ... @@ -362,7 +362,6 @@ Cannot read the previousTitle for a route that has not yet been installed''',
Widget child, {
bool limitedSwipe = false,
double initialOffset = 0,
Transition? transition,
}) {
// Check if the route has an animation that's currently participating
// in a back swipe gesture.
... ... @@ -393,9 +392,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -411,7 +410,7 @@ Cannot read the previousTitle for a route that has not yet been installed''',
final iosAnimation = animation;
animation = CurvedAnimation(parent: animation, curve: finalCurve);
switch (transition ?? Get.defaultTransition) {
switch (route.transition ?? Get.defaultTransition) {
case Transition.leftToRight:
return SlideLeftTransition().buildTransitions(
context,
... ... @@ -421,9 +420,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -442,9 +441,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -463,9 +462,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -478,9 +477,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
case Transition.noTransition:
return GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -499,9 +498,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -520,9 +519,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -541,9 +540,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -562,9 +561,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -583,9 +582,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -602,9 +601,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
linearTransition: linearTransition,
child: GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -623,9 +622,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -643,9 +642,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -663,9 +662,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -683,9 +682,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -704,9 +703,9 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(_isPopGestureEnabled(route, canSwipe(route), context));
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -731,9 +730,11 @@ Cannot read the previousTitle for a route that has not yet been installed''',
secondaryAnimation,
GetBackGestureDetector<T>(
popGestureEnable: () =>
_isPopGestureEnabled(route, canSwipe(route)),
_isPopGestureEnabled(route, canSwipe(route), context),
onStartPopGesture: () {
assert(_isPopGestureEnabled(route, canSwipe(route)));
assert(
_isPopGestureEnabled(route, canSwipe(route), context),
);
return _startPopGesture(route);
},
limitedSwipe: limitedSwipe,
... ... @@ -758,11 +759,13 @@ Cannot read the previousTitle for a route that has not yet been installed''',
///
/// * [popGestureEnabled], which returns true if a user-triggered pop gesture
/// would be allowed.
// static bool isPopGestureInProgress(PageRoute<dynamic> route) {
// return route.navigator!.userGestureInProgress;
// }
static bool isPopGestureInProgress(BuildContext context) {
final route = ModalRoute.of(context)!;
return route.navigator!.userGestureInProgress;
}
static bool _isPopGestureEnabled<T>(PageRoute<T> route, bool canSwipe) {
static bool _isPopGestureEnabled<T>(
PageRoute<T> route, bool canSwipe, BuildContext context) {
// If there's nothing to go back to, then obviously we don't support
// the back gesture.
if (route.isFirst) return false;
... ... @@ -784,7 +787,7 @@ Cannot read the previousTitle for a route that has not yet been installed''',
return false;
}
// If we're in a gesture already, we cannot start another.
if (CupertinoRouteTransitionMixin.isPopGestureInProgress(route)) {
if (GetPageRouteTransitionMixin.isPopGestureInProgress(context)) {
return false;
}
... ...
... ... @@ -147,8 +147,7 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, RouteDecoder> {
return ret;
},
emptyPage: (delegate) =>
delegate.matchRoute(initialRoute).route ??
delegate.notFoundRoute,
delegate.matchRoute(initialRoute).route ?? delegate.notFoundRoute,
key: Get.nestedKey(anchorRoute)?.navigatorKey,
delegate: delegate,
);
... ...
// ignore_for_file: overridden_fields
import 'dart:async';
import 'package:flutter/material.dart';
import '../../../instance_manager.dart';
... ... @@ -149,10 +151,10 @@ abstract class Bind<T> extends StatelessWidget {
);
}
static Bind create<S>(InstanceBuilderCallback<S> builder,
static Bind create<S>(InstanceCreateBuilderCallback<S> builder,
{String? tag, bool permanent = true}) {
Get.create<S>(builder, tag: tag, permanent: permanent);
return _FactoryBind<S>(
create: builder,
tag: tag,
);
}
... ... @@ -192,6 +194,7 @@ abstract class Bind<T> extends StatelessWidget {
factory Bind.builder({
Widget? child,
InitBuilder<T>? init,
InstanceCreateBuilderCallback<T>? create,
bool global = true,
bool autoRemove = true,
bool assignId = false,
... ... @@ -206,6 +209,7 @@ abstract class Bind<T> extends StatelessWidget {
_FactoryBind<T>(
// key: key,
init: init,
create: create,
global: global,
autoRemove: autoRemove,
assignId: assignId,
... ... @@ -254,6 +258,8 @@ class _FactoryBind<T> extends Bind<T> {
@override
final InitBuilder<T>? init;
final InstanceCreateBuilderCallback<T>? create;
@override
final bool global;
@override
... ... @@ -282,6 +288,7 @@ class _FactoryBind<T> extends Bind<T> {
Key? key,
this.child,
this.init,
this.create,
this.global = true,
this.autoRemove = true,
this.assignId = false,
... ... @@ -298,6 +305,7 @@ class _FactoryBind<T> extends Bind<T> {
Bind<T> _copyWithChild(Widget child) {
return Bind<T>.builder(
init: init,
create: create,
global: global,
autoRemove: autoRemove,
assignId: assignId,
... ... @@ -315,7 +323,7 @@ class _FactoryBind<T> extends Bind<T> {
@override
Widget build(BuildContext context) {
return Binder<T>(
init: init,
create: create,
global: global,
autoRemove: autoRemove,
assignId: assignId,
... ... @@ -367,9 +375,11 @@ class Binder<T> extends InheritedWidget {
this.id,
this.didChangeDependencies,
this.didUpdateWidget,
this.create,
}) : super(key: key, child: child);
final InitBuilder<T>? init;
final InstanceCreateBuilderCallback? create;
final bool global;
final Object? id;
final String? tag;
... ... @@ -442,7 +452,7 @@ class BindElement<T> extends InheritedElement {
_controllerBuilder = () => Get.find<T>(tag: widget.tag);
} else {
_controllerBuilder = widget.init;
_controllerBuilder = widget.create?.call(this) ?? widget.init;
_isCreator = true;
if (widget.lazy) {
Get.lazyPut<T>(_controllerBuilder!, tag: widget.tag);
... ... @@ -451,7 +461,7 @@ class BindElement<T> extends InheritedElement {
}
}
} else {
_controllerBuilder = widget.init;
_controllerBuilder = widget.create?.call(this) ?? widget.init;
_isCreator = true;
_needStart = true;
}
... ... @@ -482,6 +492,10 @@ class BindElement<T> extends InheritedElement {
_remove?.call();
localController.addListener(filter);
_remove = () => localController.removeListener(filter);
} else if (localController is StreamController) {
_remove?.call();
final stream = localController.stream.listen((_) => filter());
_remove = () => stream.cancel();
}
}
... ...
... ... @@ -91,7 +91,7 @@ class _GetCache<S extends GetLifeCycleMixin> extends WidgetCache<GetWidget<S>> {
widget!.controller.onDelete();
Get.log('"${widget!.controller.runtimeType}" onClose() called');
Get.log('"${widget!.controller.runtimeType}" deleted from memory');
GetWidget._cache[widget!] = null;
// GetWidget._cache[widget!] = null;
});
}
info = null;
... ...
import 'dart:async';
import 'dart:collection';
import 'package:flutter/foundation.dart';
... ... @@ -23,6 +24,9 @@ class ListNotifierGroup = ListNotifier with ListNotifierGroupMixin;
mixin ListNotifierSingleMixin on Listenable {
List<GetStateUpdate>? _updaters = <GetStateUpdate>[];
int _version = 0;
int _microtaskVersion = 0;
@override
Disposer addListener(GetStateUpdate listener) {
assert(_debugAssertNotDisposed());
... ... @@ -57,9 +61,16 @@ mixin ListNotifierSingleMixin on Listenable {
}
void _notifyUpdate() {
if (_microtaskVersion == _version) {
_microtaskVersion++;
scheduleMicrotask(() {
_version++;
_microtaskVersion = _version;
for (var element in _updaters!) {
element();
}
});
}
}
bool get isDisposed => _updaters == null;
... ...
import 'dart:async';
import 'package:flutter/scheduler.dart';
import 'package:flutter/widgets.dart';
import 'list_notifier.dart';
... ... @@ -70,7 +69,7 @@ class _ValueBuilderState<T> extends State<ValueBuilder<T>> {
}
}
class ObxElement = StatelessElement with ObserverComponent;
class ObxElement = StatelessElement with StatelessObserverComponent;
// It's a experimental feature
class Observer extends ObxStatelessWidget {
... ... @@ -91,31 +90,13 @@ abstract class ObxStatelessWidget extends StatelessWidget {
}
/// a Component that can track changes in a reactive variable
mixin ObserverComponent on ComponentElement {
mixin StatelessObserverComponent on StatelessElement {
List<Disposer>? disposers = <Disposer>[];
void getUpdate() {
if (disposers != null) {
_safeRebuild();
}
}
Future<bool> _safeRebuild() async {
if (dirty) return false;
if (SchedulerBinding.instance == null) {
if (disposers != null && !dirty) {
markNeedsBuild();
} else {
// refresh was called during the building
if (SchedulerBinding.instance!.schedulerPhase != SchedulerPhase.idle) {
// Await for the end of build
await SchedulerBinding.instance!.endOfFrame;
if (dirty) return false;
}
markNeedsBuild();
}
return true;
}
@override
... ...
name: get
description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX.
version: 5.0.0-beta.45
version: 5.0.0-beta.50
homepage: https://github.com/jonataslaw/getx
environment:
... ...