dart_extensions icon indicating copy to clipboard operation
dart_extensions copied to clipboard

Error in navigateBack

Open Skquark opened this issue 4 years ago • 4 comments

I want to use these extensions, but as soon as I import in my existing project, before I even used any of the methods, I'm getting this error:

Compiler message: /d:/Program%20Files/Android/flutter/.pub-cache/hosted/pub.dartlang.org/dart_extensions-0.3.4/lib/src/flutter/navigation.dart:21:49: Error: This expression has type 'void' and can't be used. bool navigateBack<T>({T result}) => Navigator.pop(context, result); ^ /d:/Program%20Files/Android/flutter/.pub-cache/hosted/pub.dartlang.org/dart_extensions-0.3.4/lib/src/flutter/navigation.dart:33:81: Error: This expression has type 'void' and can't be used.

So I checked out that file, fiddled around with it and realized you had to change bool to void (as it says) so line 21 & 33 are like this: void navigateBack<T>({T result}) => Navigator.pop(context, result); Easy enough fix, no one would need to really check for a bool result when they're navigating back, so makes sense. The code should compile once that's changed, not sure on how it would of worked for others, it's possible if it didn't give you that error that there was a breaking change in a Flutter update, dunno. Anyways, thanks, one of the better sets of extensions that I was looking for, looking forward to future helper shortcuts, maybe I'll submit a few down the line...

Skquark avatar Mar 12 '20 11:03 Skquark

Same issue here! Just installed this library and got this error message on compile.

[✓] Flutter (Channel beta, v1.15.17, on Mac OS X 10.15.3 19D76, locale en-IL)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.6)
[!] VS Code (version 1.43.1)
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (4 available)

CripyIce avatar Mar 24 '20 15:03 CripyIce

same here

jasonlaw avatar May 09 '20 03:05 jasonlaw

I'm surprised this hasn't been revised yet since I gave the fix in the question. It's official that with the latest Flutter releases that Navigator.of(context).pop and push no longer returns a bool, it returns nothing. I've been using this plugin off of my fork where I made the change, but I didn't think I needed to do a Pull Request since it was as simple as changing the bool to void...

Skquark avatar May 09 '20 11:05 Skquark

And it also does not need to be a bool because if you want to check navigation you have observers to do it

WilliamCunhaCardoso avatar Jun 23 '20 20:06 WilliamCunhaCardoso