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

Flutter run not working with null-safety flag #149

Open
brokoli18 opened this issue Dec 27, 2021 · 12 comments
Open

Flutter run not working with null-safety flag #149

brokoli18 opened this issue Dec 27, 2021 · 12 comments

Comments

@brokoli18
Copy link

Describe the bug
More recent version of flutter implement the null safety feature, which throws out errors if not run with the --no-sound-null-safety flag. When running flutter from the terminal this works as normal (even without the flag), however when using the inbuilt CocCommand flutter.run --no-sound-null-safety there are errors which indicate that this flag isnt parsed.

There is only 1 version of flutter on my system (which I reinstalled using the stable channel).

Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 77d935af4d (11 days ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1
Error: Cannot run with sound null safety, because the following dependencies don't support null safety:
.....
lib/main.dart:230:23: Error: The parameter 'controller' can't have a value of 'null' because of its type 'TextEditingController', but the implicit default value is 'null'.

To Reproduce
Steps to reproduce the behavior:

  1. run :CocCommand flutter.run --no-sound-null-safety
  2. it doesn't say anywhere that it's using the flag

Expected behavior
I expect it to use the flag and work just like the normal terminal command.

Desktop (please complete the following information):

  • OS: Windows 11
  • Vim or Neovim: Neovim
  • (Neo)vim version: NVIM v0.6.0

This is copy of #78 as it was noted there that a new ticket should be opened for this issue

@Kavantix
Copy link
Collaborator

That’s really weird, might be windows only perhaps.
Can you test what happen if you run with the —help flag instead

But on a sidenote as I believe I also mentioned in the other ticket. If you don’t want to run in sound nullsafety mode you can opt out by putting // @dart = 2.11 at the top of your main.dart which is way more convenient.

@brokoli18
Copy link
Author

@Kavantix When I run with the --help flag I get the below output, which indicates that --help was parsed properly:

undefinedRun your Flutter app on an attached device.
                                                                                                       
Global options:
   -h, --help                  Print this usage information.
...

I tried to do this on my linux machine with the same flutter version and the flutter run works without an issue, which leads me to believe that this is indeed a windows problem.

I also tried to add the // @dart = 2.11 parameter at the top of my main.dart file but the issue I had still remained

@Kavantix
Copy link
Collaborator

Interesting, can you try running with --no-sound-null-safety -v.

That the dart version comment doesn't work is even stranger, did you run without the flag after adding that line?

@Kavantix
Copy link
Collaborator

I just noticed that the documentation of the flag specifies that it works differently for flutter web:

--[no-]sound-null-safety Whether to override the inferred null safety mode. This allows null-safe libraries to depend on un-migrated (non-null safe) libraries. By default, Flutter mobile & desktop applications will attempt to run at the null safety level of their entrypoint library (usually lib/main.dart). Flutter web applications will default to sound null-safety, unless specifically configured.

Are you running on web?

@brokoli18
Copy link
Author

I am running only on my android phone for both windows and linux.

@brokoli18
Copy link
Author

That the dart version comment doesn't work is even stranger, did you run without the flag after adding that line?

I ran wthout the flag after commenting the dart version, so :CocCommand flutter.run.

I also ran with --no-sound-null-safety -v, the output of which I attached to this comment, but from having a quick glance it seems that the flag is indeed there. @Kavantix Let me know if I can provide any more diagnostic information.
log.txt

@Kavantix
Copy link
Collaborator

Well I have no idea why this would not work, or alternatively why it does work if you run directly from the console.

It is even passing the flag to the dart executable:

C:\Tools\flutter\bin\cache\dart-sdk\bin\dart.exe --disable-dart-dev C:\Tools\flutter\bin\cache\artifacts\engine\windows-x64\frontend_server.dart.snapshot --sdk-root C:\Tools\flutter\bin\cache\artifacts\engine\common\flutter_patched_sdk/ --incremental --target=flutter --debugger-module-names --experimental-emit-debug-metadata -DFLUTTER_WEB_AUTO_DETECT=true --output-dill C:\Users\User\AppData\Local\Temp\flutter_tools.32742ab\flutter_tool.2b26a192\app.dill --packages c:\Users\User\Documents\Coding\Flutter\app\.dart_tool\package_config.json -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --filesystem-scheme org-dartlang-root --initialize-from-dill build\c7922d95bf4a2462b75c84a97c312edb.cache.dill.track.dill --enable-experiment=alternative-invalidation-strategy --no-sound-null-safety

@Kavantix
Copy link
Collaborator

Can you try running directly from the console with the dart version comment and without --no-sound-null-safety

@brokoli18
Copy link
Author

Can you try running directly from the console with the dart version comment and without --no-sound-null-safety

Are you refferinig to the command you specified in #149 (comment)? I tried to run that but I dont think powershell can parse all the flags properly:

Error: Error when reading '.vm.profile=false': The system cannot find the file specified.

@Kavantix
Copy link
Collaborator

No I just mean flutter run

@brokoli18
Copy link
Author

brokoli18 commented Jan 2, 2022

Running flutter run from mthe terminal with the comment in the main.dart file results in the application startinng normally (with an unsound null safety warning). Let me know if you want me to provide the full output

@Kavantix
Copy link
Collaborator

@brokoli18 could you try to check if coc-flutter is using the same flutter executable as when you run it manually.

It might also help if you could share the normal flutter output (instructions are in the issue template)

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