Search code examples
fluttervisual-studio-codevscode-debugger

VSCode Flutter Debug and Execution given a no-sound-null-safety


Until yesterday everything worked just fine. But for publishing reasons I needed to update my flutter SDK and gradle version, and after that my VsCode debug simply stopped working. It keeps giving me the Could not find an option named "no-sound-null-safety". error.

Flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.5, on Linux Mint 21.1 5.15.0-76-generic, locale pt_BR.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2022.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.3)
[✓] VS Code (version 1.79.2)
[✓] Connected device (2 available)
[✓] Network resources

Here's my vsCode.json configs:

enter image description here enter image description here enter image description here

After I reopen the VsCode it also gives me this error:

enter image description here


Solution

  • You are using Flutter 3.10, which uses Dart 3:

    Dart 3—planned for a mid-2023 release—requires sound null safety. It will prevent code from running without null safety, or with unsound null safety. All existing code must be migrated to sound null safety to be compatible with Dart 3. To learn more, see the Dart 3 sound null safety tracking issue.

    — Unsound null safety | Dart

    So you have two options really:

    • migrate back to Dart 2, that is Flutter 3.7 or earlier,
    • migrate your code to sound null safety.