Crash when compiling null Viusual studio cant run flutter

Viewed 52

I'm just getting into Flutter, I tried to run the default flutter app on Visual Studio Code but it won't run here is the error code:

Crash when compiling null,
at character offset null:
Null check operator used on a null value
#0      InferableTypeBuilderMixin.type (package:front_end/src/fasta/builder/type_builder.dart:392:29)
#1      InferableTypeBuilder.inferType (package:front_end/src/fasta/builder/omitted_type_builder.dart:155:12)
#2      SourceLoader.performTopLevelInference (package:front_end/src/fasta/source/source_loader.dart:2358:19)
#3      KernelTarget.buildOutlines.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:532:14)
<asynchronous suspension>
#4      withCrashReporting (package:front_end/src/fasta/crash.dart:122:12)
<asynchronous suspension>
#5      _buildInternal (package:front_end/src/kernel_generator_impl.dart:139:7)
<asynchronous suspension>
#6      withCrashReporting (package:front_end/src/fasta/crash.dart:122:12)
<asynchronous suspension>
#7      generateKernel.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:47:12)
<asynchronous suspension>
#8      generateKernel (package:front_end/src/kernel_generator_impl.dart:46:10)
<asynchronous suspension>
#9      kernelForModule (package:front_end/src/api_prototype/kernel_generator.dart:100:11)
<asynchronous suspension>
#10     SingleShotCompilerWrapper.compileInternal (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:412:11)
<asynchronous suspension>
#11     Compiler.compile.<anonymous closure> (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:221:45)
<asynchronous suspension>
#12     _processLoadRequest (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:914:37)
<asynchronous suspension>


#0      InferableTypeBuilderMixin.type (package:front_end/src/fasta/builder/type_builder.dart:392:29)
#1      InferableTypeBuilder.inferType (package:front_end/src/fasta/builder/omitted_type_builder.dart:155:12)
#2      SourceLoader.performTopLevelInference (package:front_end/src/fasta/source/source_loader.dart:2358:19)
#3      KernelTarget.buildOutlines.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:532:14)
<asynchronous suspension>
#4      withCrashReporting (package:front_end/src/fasta/crash.dart:122:12)
<asynchronous suspension>
#5      _buildInternal (package:front_end/src/kernel_generator_impl.dart:139:7)
<asynchronous suspension>
#6      withCrashReporting (package:front_end/src/fasta/crash.dart:122:12)
<asynchronous suspension>
#7      generateKernel.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:47:12)
<asynchronous suspension>
#8      generateKernel (package:front_end/src/kernel_generator_impl.dart:46:10)
<asynchronous suspension>
#9      kernelForModule (package:front_end/src/api_prototype/kernel_generator.dart:100:11)
<asynchronous suspension>
#10     SingleShotCompilerWrapper.compileInternal (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:412:11)
<asynchronous suspension>
#11     Compiler.compile.<anonymous closure> (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:221:45)
<asynchronous suspension>
#12     _processLoadRequest (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:914:37)
<asynchronous suspension

I can run the code on Android Studio IDE but not on VS Code. There are no problems with flutter doctor, I have both flutter and dart extensions installed on VS Code.

4 Answers

It looks like to be a problem after the 2.0 update dart where the null safety it's not allowing you run your code with null variables, but I don't know where is this variable and I'm facing this same problem by days

I solved this problem man.

First I moved my application, that I created through the 'flutter create' code in my prompt, from C disk to D disk because I didn't have to much space on disk, after that I run the main() file in my Android Studio and then in the Visual Studio Code and it work well

Try to do it, maybe it will work for you to

Best Regards!

I tried running the flutter project with the run and debug icon in VScode with an internet connection. Also check your flutter licenses with 'flutter doctor --android-licenses'. I hope that will fix your problem.

I have this error in my dart package. I created dart package with very_good_cli. I can't run my tests from vscode. It crashes with the same log.

If I run the tests with flutter command in the terminal, it works. With dart command, it doesn't work.

I think the problem is, vscode tries to run with dart command and since project has the flutter packages, something about flutter is null there.

Solution is, creating new Flutter project if you create a dart project like me or find a way to tell vscode to run with Flutter.

I've fixed by removing test package and adding flutter_test package.

Related