Skip to content

Commit 51a01d5

Browse files
committed
fix-defaultPopGesture
1 parent f8b9d77 commit 51a01d5

File tree

13 files changed

+27
-29
lines changed

13 files changed

+27
-29
lines changed

example/.metadata

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ migration:
1515
- platform: root
1616
create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
1717
base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
18-
- platform: ios
18+
- platform: web
1919
create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
2020
base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
2121

example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ dependency_overrides:
2727
dependencies:
2828
flutter:
2929
sdk: flutter
30+
google_fonts:
3031

3132
# The following adds the Cupertino Icons font to your application.
3233
# Use with the CupertinoIcons class for iOS style icons.

lib/get_core/src/typedefs.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
11
typedef ValueUpdater<T> = T Function();
2-
3-
/// This allows a value of type T or T?
4-
/// to be treated as a value of type T?.
5-
///
6-
/// We use this so that APIs that have become
7-
/// non-nullable can still be used with `!` and `?`
8-
/// to support older versions of the API as well.
9-
T? ambiguate<T>(T? value) => value;

lib/get_instance/src/lifecycle.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mixin GetLifeCycleMixin {
1717
@protected
1818
@mustCallSuper
1919
void onInit() {
20-
ambiguate(Engine.instance)?.addPostFrameCallback((_) => onReady());
20+
Engine.instance.addPostFrameCallback((_) => onReady());
2121
}
2222

2323
/// Called 1 frame after onInit(). It is the perfect place to enter

lib/get_navigation/src/extension_navigation.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ extension ExtensionSnackbar on GetInterface {
367367
if (instantInit) {
368368
controller.show();
369369
} else {
370-
ambiguate(Engine.instance)!.addPostFrameCallback((_) {
370+
Engine.instance.addPostFrameCallback((_) {
371371
controller.show();
372372
});
373373
}
@@ -480,7 +480,7 @@ extension ExtensionSnackbar on GetInterface {
480480
controller.show();
481481
} else {
482482
//routing.isSnackbar = true;
483-
ambiguate(Engine.instance)!.addPostFrameCallback((_) {
483+
Engine.instance.addPostFrameCallback((_) {
484484
controller.show();
485485
});
486486
}
@@ -898,6 +898,13 @@ extension GetNavigationExt on GetInterface {
898898
closeOverlay(id: id, result: result);
899899
}
900900

901+
void closeBottomSheet<T>({String? id, T? result}) {
902+
// Stop if there is no bottomsheet open
903+
if (isBottomSheetOpen == null || !isBottomSheetOpen!) return;
904+
905+
closeOverlay(id: id, result: result);
906+
}
907+
901908
/// Close the current overlay returning the [result], if provided
902909
void closeOverlay<T>({
903910
String? id,
@@ -1227,9 +1234,6 @@ extension GetNavigationExt on GetInterface {
12271234
/// check a raw current route
12281235
Route<dynamic>? get rawRoute => routing.route;
12291236

1230-
/// check if popGesture is enable
1231-
bool get isPopGestureEnable => defaultPopGesture;
1232-
12331237
/// check if default opaque route is enable
12341238
bool get isOpaqueRouteDefault => defaultOpaqueRoute;
12351239

@@ -1319,7 +1323,7 @@ extension GetNavigationExt on GetInterface {
13191323

13201324
ConfigData get _getxController => GetRootState.controller.config;
13211325

1322-
bool get defaultPopGesture => _getxController.defaultPopGesture;
1326+
bool? get defaultPopGesture => _getxController.defaultPopGesture;
13231327
bool get defaultOpaqueRoute => _getxController.defaultOpaqueRoute;
13241328

13251329
Transition? get defaultTransition => _getxController.defaultTransition;

lib/get_navigation/src/root/get_cupertino_app.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ class GetCupertinoApp extends StatelessWidget {
215215
translations: translations,
216216
translationsKeys: translationsKeys,
217217
unknownRoute: unknownRoute,
218+
defaultPopGesture: popGesture,
218219
),
219220
child: Builder(builder: (context) {
220221
final controller = GetRoot.of(context);

lib/get_navigation/src/root/get_material_app.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ class GetMaterialApp extends StatelessWidget {
225225
theme: theme,
226226
darkTheme: darkTheme,
227227
themeMode: themeMode,
228+
defaultPopGesture: popGesture,
228229
),
229230
// binds: [
230231
// Bind.lazyPut<GetMaterialController>(

lib/get_navigation/src/root/get_root.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ConfigData {
3838
final ThemeData? theme;
3939
final ThemeData? darkTheme;
4040
final ThemeMode? themeMode;
41-
final bool defaultPopGesture;
41+
final bool? defaultPopGesture;
4242
final bool defaultOpaqueRoute;
4343
final Duration defaultTransitionDuration;
4444
final Curve defaultTransitionCurve;
@@ -87,10 +87,9 @@ class ConfigData {
8787
this.defaultDialogTransitionCurve = Curves.easeOutQuad,
8888
this.defaultDialogTransitionDuration = const Duration(milliseconds: 300),
8989
this.parameters = const {},
90+
required this.defaultPopGesture,
9091
Routing? routing,
91-
bool? defaultPopGesture,
92-
}) : defaultPopGesture = defaultPopGesture ?? GetPlatform.isIOS,
93-
routing = routing ?? Routing();
92+
}) : routing = routing ?? Routing();
9493

9594
ConfigData copyWith({
9695
ValueChanged<Routing?>? routingCallback,
@@ -327,7 +326,7 @@ class GetRootState extends State<GetRoot> with WidgetsBindingObserver {
327326
void initState() {
328327
config = widget.config;
329328
GetRootState._controller = this;
330-
ambiguate(Engine.instance)!.addObserver(this);
329+
Engine.instance.addObserver(this);
331330
onInit();
332331
super.initState();
333332
}
@@ -349,7 +348,7 @@ class GetRootState extends State<GetRoot> with WidgetsBindingObserver {
349348
RouterReportManager.dispose();
350349
Get.resetInstance(clearRouteBindings: true);
351350
_controller = null;
352-
ambiguate(Engine.instance)!.removeObserver(this);
351+
Engine.instance.removeObserver(this);
353352
}
354353

355354
@override

lib/get_navigation/src/router_report.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class RouterReportManager<T> {
5959

6060
void reportRouteDispose(T disposed) {
6161
if (Get.smartManagement != SmartManagement.onlyBuilder) {
62-
// ambiguate(Engine.instance)!.addPostFrameCallback((_) {
62+
// Engine.instance.addPostFrameCallback((_) {
6363
// Future.microtask(() {
6464
_removeDependencyByRoute(disposed);
6565
// });

lib/get_navigation/src/routes/get_transition_mixin.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ Cannot read the previousTitle for a route that has not yet been installed''',
339339
}
340340

341341
static bool canSwipe(GetPageRoute route) =>
342-
route.popGesture ?? Get.defaultPopGesture;
342+
route.popGesture ?? Get.defaultPopGesture ?? GetPlatform.isIOS;
343343

344344
/// Returns a [CupertinoFullscreenDialogTransition] if [route] is a full
345345
/// screen dialog, otherwise a [CupertinoPageTransition] is returned.

0 commit comments

Comments
 (0)