Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defaultDialog cancel: Widget is not of type bool #85

Closed
mstachalski opened this issue May 10, 2020 · 4 comments
Closed

defaultDialog cancel: Widget is not of type bool #85

mstachalski opened this issue May 10, 2020 · 4 comments
Assignees

Comments

@mstachalski
Copy link

Describe the bug
Hello, since I upgraded to the latest version of Get (2.2.2) all my defaultDialogs stopped working.
More specifically the cancel: and confirm: properties which used to take widgets before are throwing errors that whatever was passed is not of type bool.

To Reproduce
Steps to reproduce the behavior:

  1. Create a defaultDialog with a cancel property and a flatbutton
  2. Run the app with flutter run
  3. Do something that makes the dialog pop up
  4. Get the error

Expected behavior
A dialog should pop up with a flatbutton that allows to execute a function when pressed

Flutter Version:
1.17.0

Get Version:
2.2.2

Describe on which device you found the bug:
Pixel 3a

Minimal reproduce code
Provide a minimum reproduction code for the problem
Get.defaultDialog( title: "Logout", content: Text("Möchtest du dich ausloggen?"), cancel: FlatButton( onPressed: () { Get.back(); }, child: Text("Abbrechen")), confirm: FlatButton( onPressed: () { storage.delete(key: _jwtKey); storage.delete(key: _refreshKey); RequestQueueTimer.stopTimer(); Get.off(LoginScreen()); }, child: Text("OK"), ), );

@mstachalski
Copy link
Author

Stacktrace:

I/flutter (20027): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════ I/flutter (20027): The following _TypeError was thrown while handling a gesture: I/flutter (20027): type 'FlatButton' is not a subtype of type 'bool' I/flutter (20027): I/flutter (20027): When the exception was thrown, this was the stack: I/flutter (20027): #0 Get.defaultDialog (package:get/src/get_main.dart:254:34) I/flutter (20027): #1 JWTAuthenticationHandler.logOut (package:bar_bachelor/helpers/jwtAuthenticationHandler.dart:208:9) I/flutter (20027): #2 MyScaffold.build.<anonymous closure> (package:bar_bachelor/widgets/myScaffold.dart:33:50) I/flutter (20027): #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19) I/flutter (20027): #4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:862:36) I/flutter (20027): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24) I/flutter (20027): #6 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11) I/flutter (20027): #7 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5) I/flutter (20027): #8 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:217:7) I/flutter (20027): #9 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:475:9) I/flutter (20027): #10 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12) I/flutter (20027): #11 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9) I/flutter (20027): #12 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8) I/flutter (20027): #13 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18) I/flutter (20027): #14 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7) I/flutter (20027): #15 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19) I/flutter (20027): #16 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22) I/flutter (20027): #17 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7) I/flutter (20027): #18 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7) I/flutter (20027): #19 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7) I/flutter (20027): #23 _invoke1 (dart:ui/hooks.dart:275:10) I/flutter (20027): #24 _dispatchPointerDataPacket (dart:ui/hooks.dart:184:5) I/flutter (20027): (elided 3 frames from dart:async) I/flutter (20027): I/flutter (20027): Handler: "onTap" I/flutter (20027): Recognizer: I/flutter (20027): TapGestureRecognizer#ef982 I/flutter (20027): ════════════════════════════════════════════════════════════════════════════════════════════════════

@jonataslaw
Copy link
Owner

Lol, the Dart compiler is crazy and returning before the end of the statement. I'm going to open an issue at Dart-lang and do some alternative work for that, like wrapping everything up in parentheses.
You don't need to use widgets either, using this may make your code even smaller:

 Get.defaultDialog(
          title: "Logout",
          content: Text("Möchtest du dich ausloggen?"),
          textCancel: "Abbrechen",
          textConfirm: "Ok",
          onConfirm: () {
            storage.delete(key: _jwtKey);
            storage.delete(key: _refreshKey);
            RequestQueueTimer.stopTimer();
            Get.off(LoginScreen());
          },
        );

@mstachalski
Copy link
Author

Hey, thank you for the really quick reply!

I am going to do that then. Hoped there would be a faster solution than to rewrite all the default dialogs though, but seems like it can't be helped!

Thanks!

@jonataslaw
Copy link
Owner

Fix on 2.2.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants