Flutter 中的编译错误:NoSuchMethodError:getter“isEof”在 null 上被调用

Flutter 中的编译错误:NoSuchMethodError:getter“isEof”在 null 上被调用

当我尝试在模拟器上调试 Flutter 应用时,我随机开始收到此编译错误。我尝试将 Flutter 升级到最新版本。我的代码中没有出现任何格式或其他错误。我唯一能想到的可能是我在另一台计算机上更改了 dart 文件的编码,这是使用记事本导致问题的根本原因。

registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
U
nhandled exception:
Crash when compiling package:prep_ace/Pages/Engli
sh/en_additional_resource.dart,
at character offset null:
NoSuchMethodError: The getter 'isEof' was called on null.
Receiver: null
Tried calling: isEof
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      scannerRecovery 
#2      _tokenizeAndRecover (package:front_end/src/fasta/scanner.dart:103:14)
#3      scan (package:front_end/src/fasta/scanner.dart:82:10)
#4      SourceLoader.tokenize (package:front_end/src/fasta/source/source_loader.dart:207:28)
<asynchronous suspension>
#5      SourceLoader.buildOutline (package:front_end/src/fasta/source/source_loader.dart:281:26)
<asynchronous suspension>
#6      Loader.buildOutlines (package:front_end/src/fasta/loader.dart:239:13)
<asynchronous suspension>
#7      KernelTarget.buildOutlines.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:248:20)
<asynchronous suspension>
#8      withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)

<asynchronous suspension>
#9      KernelTarget.buildOutlines (package:front_end/src/fasta/kernel/kernel_target.dart:246:12)

<asynchronous suspension>
#10     generateKernelInternal.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:117:28)
<asynchronous suspension>
#11     withCrashReporting (p
ackage:front_end/src/fasta/crash.dart:122:24)
<asynchronous suspension>
#12     generateKernelInternal (package:front_end/src/kernel_generator_impl.dart:65:10)
<asynchronous
 suspension>
#13     kernelForProgramInternal.<anonymous closure> 
<asynchronous suspension>
#14     CompilerContext.runWithOptions.<anonymous cl
osure> (package:front_end/src/fasta/compiler_context.dart:134:20)
<asynchronous suspension>
#15     CompilerContext.runInC
ontext.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:46)
#16     new Future.sync (dart
:async/future.dart:224:31)
#17     CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:19)
#18     _rootRun (dar
t:async/zone.dart:1124:13)
#20     _runZoned (dart:async/zone.dart:1516:10)
#21     runZoned (dart:async/zone.dart:1463:12)
#22     
CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:121:12)
#23     CompilerContext.runWithOptions (package:front_end/src/fasta/compiler_context.dart:132:10)
#24     kernelForProgramInternal (package:front_end/src/api_prototype/kern
el_generator.dart:58:32)
<asynchronous suspension>
#25     kernelForProgram (package:front_end/src/api_prototype/
kernel_generator.dart:51:17)
<asynchronous suspension>
#26     compileToKernel (package:vm/kernel_front_end.dart:295:41)
<asynchronous suspension>
#27  
   FrontendCompiler.compile.<anonymous closure> (package:vm/frontend_server.dart:383:56)
#29     _rootRun (dart:async/zone.dart:1120:38)

#30     _CustomZone.run (dart:async/zone.dart:1021:19)
#31     _Cust
omZone.runGuarded (dart:async/zone.dart:923:7)
#33     _rootRun (dart:async/zone.dart:1124:13)

#34     _CustomZone.ru
n (dart:async/zone.dart:1021:19)
#35     _CustomZone.bindCallback.<anonymous c
losure> (dart:async/zone.dart:947:23)
#36     Timer._createTimer.<anonymous clos
ure> (dart:async-patch/timer_patch.dart:21:15)
#37     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)
#38     _Timer._handle
#39     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)



#0     
 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      scannerRecovery 
#3      scan 
#4      SourceLoader.token
ize (package:front_end/src/fasta/source/source_loader.dart:207:28)
<asynchronous suspension>
#5      SourceLoader.buildOutline (package:front_end/src/fasta/source/source_loader.dart:281:26)
<asynchronous suspension>
#6      Loader.buildOu
tlines (package:front_end/src/fasta/loader.dart:239:13)
<asynchronous suspension>
#7      KernelT
#10     generateKernelInternal.<anonymous closure> 
<asynchronous s
uspension>
#11     withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)
<asynchronou
s suspension>
#12     generateKernelInternal (package:front_end/src/kernel_generator_impl.dart:65:10)
<asynchronous suspension>
#13     kernelForProgramInternal
.<anonymous closure> (package:front_end/src/api_prototype/kernel_generator.dart:59:35)
<asynchronous su
spension>
#14     CompilerContext.runWithOptions.<anonymous closure> (package:front_end/src/fasta/compi
ler_context.dart:134:20)
<asynchronous suspension>
#15     CompilerContext.runInContex
t.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_conte
xt.dart:122:46)
#16     new Future.sync (dart:async/future.dart:224:31)
#17     CompilerCo
ntext.runInContext.<anonymous closure> (package:front_end/src/fasta/compile
r_context.dart:122:19)
#18     _rootRun (dart:async/zone.dart:1124:13)
#19     _CustomZone.r
un (dart:async/zone.dart:1021:19)
#20     _runZoned (dart:async/zone.dart:1516:10)
#21     runZone
d (dart:async/zone.dart:1463:12)
#22     CompilerContext.runInContext (package:front_end/src/fas
ta/compiler_context.dart:121:12)
#24     kernelForProgramInternal 
<async
hronous suspension>
#25     kernelForProgram (package:front_end/src/api_prototype/kernel_generator.dart:51:17)
<asynchronous susp
ension>
#26     compileToKernel (package:vm/kernel_front_end.dart:295:41)
<asynchronous suspension>
#27     FrontendCompiler.compile.<an
#28     new Future.<anonymous closure> (dart:async/future.dart:176:37)
#29     _
rootRun (dart:async/zone.dart:1120:38)#30     _CustomZone.run (dart:async/zone.dart:1021:19)
#31     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#
32     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#33     _rootRun (dart:async/zone.dart:1124:13)
#34     _CustomZ
one.run (dart:async/zone.dart:1021:19)
#35     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#36     Timer._createTim
er.<anonymous closure> (dart:async-patch/timer_patch.dart:21:15)
#37     _Timer._runTimers (dart:isolate-patch/timer_impl
.dart:382:19)
#38     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
#39     _RawReceivePortImpl._handleMe
ssage (dart:isolate-patch/isolate_patch.dart:172:12)

Compiler failed on D:\OneDrive\Apps in Progress\prep_ace\prep_ace\lib\main.dart

FAILURE: Build failed with an exception.

* Where:
Script 'D:\OneDrive\Apps in Progress\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 765

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebugX86'.
> Process 'command 'D:\OneDrive\Apps in Progress\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

代码中我没有发现任何错误。对于我还没有真正开始处理的页面来说,这都是非常简单的基本代码。这样的事情会导致这个错误吗?

答案1

刚刚确认了我自己的想法,这是记事本的编码。我将其更改为 UTF-16,而 dart 文件的默认编码是 UTF-8。我想这在 Flutter 中很重要。

相关内容