Jonny Borges
Committed by GitHub

Merge pull request #1257 from maxzod/master

better error message for navigation
@@ -251,8 +251,7 @@ extension ExtensionDialog on GetInterface { @@ -251,8 +251,7 @@ extension ExtensionDialog on GetInterface {
251 ); 251 );
252 }, 252 },
253 useRootNavigator: useRootNavigator, 253 useRootNavigator: useRootNavigator,
254 - routeSettings:  
255 - routeSettings ?? RouteSettings(arguments: arguments, name: name), 254 + routeSettings: routeSettings ?? RouteSettings(arguments: arguments, name: name),
256 ); 255 );
257 } 256 }
258 257
@@ -268,8 +267,7 @@ extension ExtensionDialog on GetInterface { @@ -268,8 +267,7 @@ extension ExtensionDialog on GetInterface {
268 RouteSettings? routeSettings, 267 RouteSettings? routeSettings,
269 }) { 268 }) {
270 assert(!barrierDismissible || barrierLabel != null); 269 assert(!barrierDismissible || barrierLabel != null);
271 - return Navigator.of(overlayContext!, rootNavigator: useRootNavigator)  
272 - .push<T>(GetDialogRoute<T>( 270 + return Navigator.of(overlayContext!, rootNavigator: useRootNavigator).push<T>(GetDialogRoute<T>(
273 pageBuilder: pageBuilder, 271 pageBuilder: pageBuilder,
274 barrierDismissible: barrierDismissible, 272 barrierDismissible: barrierDismissible,
275 barrierLabel: barrierLabel, 273 barrierLabel: barrierLabel,
@@ -321,10 +319,7 @@ extension ExtensionDialog on GetInterface { @@ -321,10 +319,7 @@ extension ExtensionDialog on GetInterface {
321 tapTargetSize: MaterialTapTargetSize.shrinkWrap, 319 tapTargetSize: MaterialTapTargetSize.shrinkWrap,
322 padding: EdgeInsets.symmetric(horizontal: 10, vertical: 8), 320 padding: EdgeInsets.symmetric(horizontal: 10, vertical: 8),
323 shape: RoundedRectangleBorder( 321 shape: RoundedRectangleBorder(
324 - side: BorderSide(  
325 - color: buttonColor ?? theme!.accentColor,  
326 - width: 2,  
327 - style: BorderStyle.solid), 322 + side: BorderSide(color: buttonColor ?? theme!.accentColor, width: 2, style: BorderStyle.solid),
328 borderRadius: BorderRadius.circular(100)), 323 borderRadius: BorderRadius.circular(100)),
329 ), 324 ),
330 onPressed: () { 325 onPressed: () {
@@ -347,13 +342,11 @@ extension ExtensionDialog on GetInterface { @@ -347,13 +342,11 @@ extension ExtensionDialog on GetInterface {
347 tapTargetSize: MaterialTapTargetSize.shrinkWrap, 342 tapTargetSize: MaterialTapTargetSize.shrinkWrap,
348 //color: buttonColor ?? theme.accentColor, 343 //color: buttonColor ?? theme.accentColor,
349 backgroundColor: buttonColor ?? theme!.accentColor, 344 backgroundColor: buttonColor ?? theme!.accentColor,
350 - shape: RoundedRectangleBorder(  
351 - borderRadius: BorderRadius.circular(100)), 345 + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(100)),
352 ), 346 ),
353 child: Text( 347 child: Text(
354 textConfirm ?? "Ok", 348 textConfirm ?? "Ok",
355 - style:  
356 - TextStyle(color: confirmTextColor ?? theme!.backgroundColor), 349 + style: TextStyle(color: confirmTextColor ?? theme!.backgroundColor),
357 ), 350 ),
358 onPressed: () { 351 onPressed: () {
359 onConfirm?.call(); 352 onConfirm?.call();
@@ -365,16 +358,13 @@ extension ExtensionDialog on GetInterface { @@ -365,16 +358,13 @@ extension ExtensionDialog on GetInterface {
365 titlePadding: EdgeInsets.all(8), 358 titlePadding: EdgeInsets.all(8),
366 contentPadding: EdgeInsets.all(8), 359 contentPadding: EdgeInsets.all(8),
367 backgroundColor: backgroundColor ?? theme!.dialogBackgroundColor, 360 backgroundColor: backgroundColor ?? theme!.dialogBackgroundColor,
368 - shape: RoundedRectangleBorder(  
369 - borderRadius: BorderRadius.all(Radius.circular(radius))), 361 + shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(radius))),
370 title: Text(title, textAlign: TextAlign.center, style: titleStyle), 362 title: Text(title, textAlign: TextAlign.center, style: titleStyle),
371 content: Column( 363 content: Column(
372 crossAxisAlignment: CrossAxisAlignment.center, 364 crossAxisAlignment: CrossAxisAlignment.center,
373 mainAxisSize: MainAxisSize.min, 365 mainAxisSize: MainAxisSize.min,
374 children: [ 366 children: [
375 - content ??  
376 - Text(middleText,  
377 - textAlign: TextAlign.center, style: middleTextStyle), 367 + content ?? Text(middleText, textAlign: TextAlign.center, style: middleTextStyle),
378 SizedBox(height: 16), 368 SizedBox(height: 16),
379 ButtonTheme( 369 ButtonTheme(
380 minWidth: 78.0, 370 minWidth: 78.0,
@@ -427,15 +417,13 @@ extension ExtensionBottomSheet on GetInterface { @@ -427,15 +417,13 @@ extension ExtensionBottomSheet on GetInterface {
427 Duration? enterBottomSheetDuration, 417 Duration? enterBottomSheetDuration,
428 Duration? exitBottomSheetDuration, 418 Duration? exitBottomSheetDuration,
429 }) { 419 }) {
430 - return Navigator.of(overlayContext!, rootNavigator: useRootNavigator)  
431 - .push(GetModalBottomSheetRoute<T>( 420 + return Navigator.of(overlayContext!, rootNavigator: useRootNavigator).push(GetModalBottomSheetRoute<T>(
432 builder: (_) => bottomsheet, 421 builder: (_) => bottomsheet,
433 isPersistent: persistent, 422 isPersistent: persistent,
434 // theme: Theme.of(key.currentContext, shadowThemeOnly: true), 423 // theme: Theme.of(key.currentContext, shadowThemeOnly: true),
435 theme: Theme.of(key!.currentContext!), 424 theme: Theme.of(key!.currentContext!),
436 isScrollControlled: isScrollControlled, 425 isScrollControlled: isScrollControlled,
437 - barrierLabel: MaterialLocalizations.of(key!.currentContext!)  
438 - .modalBarrierDismissLabel, 426 + barrierLabel: MaterialLocalizations.of(key!.currentContext!).modalBarrierDismissLabel,
439 backgroundColor: backgroundColor ?? Colors.transparent, 427 backgroundColor: backgroundColor ?? Colors.transparent,
440 elevation: elevation, 428 elevation: elevation,
441 shape: shape, 429 shape: shape,
@@ -514,11 +502,13 @@ extension GetNavigation on GetInterface { @@ -514,11 +502,13 @@ extension GetNavigation on GetInterface {
514 if (page is GetPageBuilder) { 502 if (page is GetPageBuilder) {
515 return page; 503 return page;
516 } else if (page is Widget) { 504 } else if (page is Widget) {
517 - Get.log(  
518 - '''WARNING, consider using: "Get.$method(() => Page())" instead of "Get.$method(Page())". 505 + Get.log('''WARNING, consider using: "Get.$method(() => Page())" instead of "Get.$method(Page())".
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. 506 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 '''); 507 ''');
521 return () => page; 508 return () => page;
  509 + } else if (page is String) {
  510 + throw '''Unexpected String,
  511 +use toNamed() instead''';
522 } else { 512 } else {
523 throw '''Unexpected format, 513 throw '''Unexpected format,
524 you can only use widgets and widget functions here'''; 514 you can only use widgets and widget functions here''';
@@ -759,12 +749,10 @@ you can only use widgets and widget functions here'''; @@ -759,12 +749,10 @@ you can only use widgets and widget functions here''';
759 } 749 }
760 750
761 /// Returns true if a Snackbar, Dialog or BottomSheet is currently OPEN 751 /// Returns true if a Snackbar, Dialog or BottomSheet is currently OPEN
762 - bool get isOverlaysOpen =>  
763 - (isSnackbarOpen! || isDialogOpen! || isBottomSheetOpen!); 752 + bool get isOverlaysOpen => (isSnackbarOpen! || isDialogOpen! || isBottomSheetOpen!);
764 753
765 /// Returns true if there is no Snackbar, Dialog or BottomSheet open 754 /// Returns true if there is no Snackbar, Dialog or BottomSheet open
766 - bool get isOverlaysClosed =>  
767 - (!isSnackbarOpen! && !isDialogOpen! && !isBottomSheetOpen!); 755 + bool get isOverlaysClosed => (!isSnackbarOpen! && !isDialogOpen! && !isBottomSheetOpen!);
768 756
769 /// **Navigation.popUntil()** shortcut.<br><br> 757 /// **Navigation.popUntil()** shortcut.<br><br>
770 /// 758 ///
@@ -1139,8 +1127,7 @@ Since version 2.8 it is possible to access the properties @@ -1139,8 +1127,7 @@ Since version 2.8 it is possible to access the properties
1139 bool get isDarkMode => (theme!.brightness == Brightness.dark); 1127 bool get isDarkMode => (theme!.brightness == Brightness.dark);
1140 1128
1141 /// Check if dark mode theme is enable on platform on android Q+ 1129 /// Check if dark mode theme is enable on platform on android Q+
1142 - bool get isPlatformDarkMode =>  
1143 - (ui.window.platformBrightness == Brightness.dark); 1130 + bool get isPlatformDarkMode => (ui.window.platformBrightness == Brightness.dark);
1144 1131
1145 /// give access to Theme.of(context).iconTheme.color 1132 /// give access to Theme.of(context).iconTheme.color
1146 Color? get iconColor => theme?.iconTheme.color; 1133 Color? get iconColor => theme?.iconTheme.color;
@@ -1182,15 +1169,13 @@ Since version 2.8 it is possible to access the properties @@ -1182,15 +1169,13 @@ Since version 2.8 it is possible to access the properties
1182 Routing get routing => getxController.routing; 1169 Routing get routing => getxController.routing;
1183 1170
1184 Map<String, String?> get parameters => getxController.parameters; 1171 Map<String, String?> get parameters => getxController.parameters;
1185 - set parameters(Map<String, String?> newParameters) =>  
1186 - getxController.parameters = newParameters; 1172 + set parameters(Map<String, String?> newParameters) => getxController.parameters = newParameters;
1187 1173
1188 ParseRouteTree get routeTree => getxController.routeTree; 1174 ParseRouteTree get routeTree => getxController.routeTree;
1189 set routeTree(ParseRouteTree tree) => getxController.routeTree = tree; 1175 set routeTree(ParseRouteTree tree) => getxController.routeTree = tree;
1190 1176
1191 CustomTransition? get customTransition => getxController.customTransition; 1177 CustomTransition? get customTransition => getxController.customTransition;
1192 - set customTransition(CustomTransition? newTransition) =>  
1193 - getxController.customTransition = newTransition; 1178 + set customTransition(CustomTransition? newTransition) => getxController.customTransition = newTransition;
1194 1179
1195 bool get testMode => getxController.testMode; 1180 bool get testMode => getxController.testMode;
1196 set testMode(bool isTest) => getxController.testMode = isTest; 1181 set testMode(bool isTest) => getxController.testMode = isTest;