Home > Blockchain >  error: lambda expressions are not supported in -source 7 when compile the flutter app
error: lambda expressions are not supported in -source 7 when compile the flutter app

Time:11-14

Today When I compile the flutter(2.5.x) project, shows error like this:

/Users/dolphin/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-5.0.0/android/src/main/java/com/it_nomads/fluttersecurestorage/FlutterSecureStoragePlugin.java:250: error: lambda expressions are not supported in -source 7
            handler.post(() -> methodResult.success(result));
                            ^
  (use -source 8 or higher to enable lambda expressions)
/Users/dolphin/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-5.0.0/android/src/main/java/com/it_nomads/fluttersecurestorage/FlutterSecureStoragePlugin.java:260: error: method references are not supported in -source 7
            handler.post(methodResult::notImplemented);
                                       ^
  (use -source 8 or higher to enable method references)
2 errors

FAILURE: Build failed with an exception.

why shows error like this? what should I do to fix this problem? what should I do to specify the java version in flutter project?

CodePudding user response:

Clear .pub-cache using rm -r ~/.pub-cache in terminal.

Please note this will delete .pub-cache folder from your computer

Run flutter clean, flutter pub get and then flutter run. It should work as expected.

CodePudding user response:

Seems a new flutter_secure_storage version issue, you should wait for the next version to fix. More information aoubt this issue:https://github.com/mogol/flutter_secure_storage/issues/330 to avoid this problem, tried to downgrade the version to 4.2.1.

  • Related