Jonny Borges
Committed by GitHub

Merge pull request #2360 from arjundevlucid/master

Fixed backward compatibility
typedef ValueUpdater<T> = T Function();
/// This allows a value of type T or T?
/// to be treated as a value of type T?.
///
/// We use this so that APIs that have become
/// non-nullable can still be used with `!` and `?`
/// to support older versions of the API as well.
T? ambiguate<T>(T? value) => value;
... ...
import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart';
import '../../get.dart';
/// The [GetLifeCycle]
///
/// ```dart
... ... @@ -16,7 +18,8 @@ mixin GetLifeCycleMixin {
@protected
@mustCallSuper
void onInit() {
SchedulerBinding.instance?.addPostFrameCallback((_) => onReady());
ambiguate(SchedulerBinding.instance)
?.addPostFrameCallback((_) => onReady());
}
/// Called 1 frame after onInit(). It is the perfect place to enter
... ...
... ... @@ -358,7 +358,7 @@ extension ExtensionSnackbar on GetInterface {
if (instantInit) {
controller.show();
} else {
SchedulerBinding.instance!.addPostFrameCallback((_) {
ambiguate(SchedulerBinding.instance)!.addPostFrameCallback((_) {
controller.show();
});
}
... ... @@ -469,7 +469,7 @@ extension ExtensionSnackbar on GetInterface {
controller.show();
} else {
//routing.isSnackbar = true;
SchedulerBinding.instance!.addPostFrameCallback((_) {
ambiguate(SchedulerBinding.instance)!.addPostFrameCallback((_) {
controller.show();
});
}
... ... @@ -544,8 +544,10 @@ extension GetNavigationExt on GetInterface {
// return page;
// } else if (page is Widget) {
// Get.log(
// '''WARNING, consider using: "Get.$method(() => Page())" instead of "Get.$method(Page())".
// 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.
// '''WARNING, consider using: "Get.$method(() => Page())"
//instead of "Get.$method(Page())".
// 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.
// ''');
// return () => page;
// } else if (page is String) {
... ...
... ... @@ -52,7 +52,7 @@ class RouterReportManager<T> {
void reportRouteDispose(T disposed) {
if (Get.smartManagement != SmartManagement.onlyBuilder) {
WidgetsBinding.instance!.addPostFrameCallback((_) {
ambiguate(WidgetsBinding.instance)!.addPostFrameCallback((_) {
_removeDependencyByRoute(disposed);
});
}
... ...
... ... @@ -34,6 +34,7 @@ class GetNavigator extends Navigator {
settings: settings,
);
}
return null;
},
reportsRouteUpdateToEngine: reportsRouteUpdateToEngine,
restorationScopeId: restorationScopeId,
... ...
... ... @@ -326,7 +326,8 @@ class GetDelegate extends RouterDelegate<RouteDecoder>
PreventDuplicateHandlingMode.ReorderRoutes,
}) async {
routeName = _cleanRouteName("/${page.runtimeType}");
// if (preventDuplicateHandlingMode == PreventDuplicateHandlingMode.Recreate) {
// if (preventDuplicateHandlingMode ==
// PreventDuplicateHandlingMode.Recreate) {
// routeName = routeName + page.hashCode.toString();
// }
... ...
... ... @@ -449,7 +449,7 @@ You need to either use message[String], or messageText[Widget] or define a userI
}
void _configureLeftBarFuture() {
SchedulerBinding.instance!.addPostFrameCallback(
ambiguate(SchedulerBinding.instance)!.addPostFrameCallback(
(_) {
final keyContext = _backgroundBoxKey.currentContext;
if (keyContext != null) {
... ...
... ... @@ -248,18 +248,21 @@ extension RxnBoolExt on Rx<bool?> {
bool? get isFalse {
if (value != null) return !isTrue!;
return null;
}
bool? operator &(bool other) {
if (value != null) {
return other && value!;
}
return null;
}
bool? operator |(bool other) {
if (value != null) {
return other || value!;
}
return null;
}
bool? operator ^(bool other) => !other == value;
... ...
... ... @@ -269,6 +269,7 @@ extension RxnNumExt<T extends num> on Rx<T?> {
if (value != null) {
return value! * other;
}
return null;
}
/// Euclidean modulo operator.
... ... @@ -288,6 +289,7 @@ extension RxnNumExt<T extends num> on Rx<T?> {
if (value != null) {
return value! % other;
}
return null;
}
/// Division operator.
... ... @@ -295,6 +297,7 @@ extension RxnNumExt<T extends num> on Rx<T?> {
if (value != null) {
return value! / other;
}
return null;
}
/// Truncating division operator.
... ... @@ -308,6 +311,7 @@ extension RxnNumExt<T extends num> on Rx<T?> {
if (value != null) {
return value! ~/ other;
}
return null;
}
/// Negate operator.
... ... @@ -315,6 +319,7 @@ extension RxnNumExt<T extends num> on Rx<T?> {
if (value != null) {
return -value!;
}
return null;
}
/// Returns the remainder of the truncating division of `this` by [other].
... ... @@ -330,6 +335,7 @@ extension RxnNumExt<T extends num> on Rx<T?> {
if (value != null) {
return value! < other;
}
return null;
}
/// Relational less than or equal operator.
... ... @@ -337,6 +343,7 @@ extension RxnNumExt<T extends num> on Rx<T?> {
if (value != null) {
return value! <= other;
}
return null;
}
/// Relational greater than operator.
... ... @@ -344,6 +351,7 @@ extension RxnNumExt<T extends num> on Rx<T?> {
if (value != null) {
return value! > other;
}
return null;
}
/// Relational greater than or equal operator.
... ... @@ -351,6 +359,7 @@ extension RxnNumExt<T extends num> on Rx<T?> {
if (value != null) {
return value! >= other;
}
return null;
}
/// True if the number is the double Not-a-Number value; otherwise, false.
... ... @@ -585,6 +594,7 @@ class RxnNum extends Rx<num?> {
value = value! + other;
return value;
}
return null;
}
/// Subtraction operator.
... ... @@ -593,6 +603,7 @@ class RxnNum extends Rx<num?> {
value = value! - other;
return value;
}
return null;
}
}
... ... @@ -711,6 +722,7 @@ extension RxnDoubleExt on Rx<double?> {
value = value! + other;
return this;
}
return null;
}
/// Subtraction operator.
... ... @@ -719,6 +731,7 @@ extension RxnDoubleExt on Rx<double?> {
value = value! + other;
return this;
}
return null;
}
/// Multiplication operator.
... ... @@ -726,12 +739,14 @@ extension RxnDoubleExt on Rx<double?> {
if (value != null) {
return value! * other;
}
return null;
}
double? operator %(num other) {
if (value != null) {
return value! % other;
}
return null;
}
/// Division operator.
... ... @@ -739,6 +754,7 @@ extension RxnDoubleExt on Rx<double?> {
if (value != null) {
return value! / other;
}
return null;
}
/// Truncating division operator.
... ... @@ -749,6 +765,7 @@ extension RxnDoubleExt on Rx<double?> {
if (value != null) {
return value! ~/ other;
}
return null;
}
/// Negate operator. */
... ... @@ -756,6 +773,7 @@ extension RxnDoubleExt on Rx<double?> {
if (value != null) {
return -value!;
}
return null;
}
/// Returns the absolute value of this [double].
... ... @@ -1104,6 +1122,7 @@ extension RxnIntExt on Rx<int?> {
if (value != null) {
return value! & other;
}
return null;
}
/// Bit-wise or operator.
... ... @@ -1118,6 +1137,7 @@ extension RxnIntExt on Rx<int?> {
if (value != null) {
return value! | other;
}
return null;
}
/// Bit-wise exclusive-or operator.
... ... @@ -1132,6 +1152,7 @@ extension RxnIntExt on Rx<int?> {
if (value != null) {
return value! ^ other;
}
return null;
}
/// The bit-wise negate operator.
... ... @@ -1144,6 +1165,7 @@ extension RxnIntExt on Rx<int?> {
if (value != null) {
return ~value!;
}
return null;
}
/// Shift the bits of this integer to the left by [shiftAmount].
... ... @@ -1160,6 +1182,7 @@ extension RxnIntExt on Rx<int?> {
if (value != null) {
return value! << shiftAmount;
}
return null;
}
/// Shift the bits of this integer to the right by [shiftAmount].
... ... @@ -1173,6 +1196,7 @@ extension RxnIntExt on Rx<int?> {
if (value != null) {
return value! >> shiftAmount;
}
return null;
}
/// Returns this integer to the power of [exponent] modulo [modulus].
... ... @@ -1290,6 +1314,7 @@ extension RxnIntExt on Rx<int?> {
if (value != null) {
return -value!;
}
return null;
}
/// Returns the absolute value of this integer.
... ...
... ... @@ -96,13 +96,13 @@ mixin FullLifeCycleMixin on FullLifeCycleController {
@override
void onInit() {
super.onInit();
WidgetsBinding.instance!.addObserver(this);
ambiguate(WidgetsBinding.instance)!.addObserver(this);
}
@mustCallSuper
@override
void onClose() {
WidgetsBinding.instance!.removeObserver(this);
ambiguate(WidgetsBinding.instance)!.removeObserver(this);
super.onClose();
}
... ...
... ... @@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/scheduler.dart';
import 'package:flutter/widgets.dart';
import '../../../get_core/src/typedefs.dart';
import 'list_notifier.dart';
typedef ValueBuilderUpdateCallback<T> = void Function(T snapshot);
... ... @@ -102,13 +103,14 @@ mixin ObserverComponent on ComponentElement {
Future<bool> _safeRebuild() async {
if (dirty) return false;
if (SchedulerBinding.instance == null) {
if (ambiguate(SchedulerBinding.instance) == null) {
markNeedsBuild();
} else {
// refresh was called during the building
if (SchedulerBinding.instance!.schedulerPhase != SchedulerPhase.idle) {
if (ambiguate(SchedulerBinding.instance)!.schedulerPhase
!= SchedulerPhase.idle) {
// Await for the end of build
await SchedulerBinding.instance!.endOfFrame;
await ambiguate(SchedulerBinding.instance)!.endOfFrame;
if (dirty) return false;
}
... ...
void main() {
// testWidgets('Back swipe dismiss interrupted by route push', (tester) async {
// testWidgets('Back swipe dismiss interrupted by route push',
// (tester) async {
// // final scaffoldKey = GlobalKey();
// await tester.pumpWidget(
... ... @@ -59,7 +60,8 @@ void main() {
// expect(find.text('push'), findsOneWidget);
// expect(
// tester.getTopLeft(find.ancestor(
// of: find.text('push'), matching: find.byType(CupertinoPageScaffold))),
// of: find.text('push'),
// matching: find.byType(CupertinoPageScaffold))),
// Offset.zero,
// );
// expect(find.text('route'), findsNothing);
... ...