flutter 在StatefulElement.state中对空值使用了空值检查运算符,

hwamh0ep  于 6个月前  发布在  Flutter
关注(0)|答案(1)|浏览(71)

重现步骤

不知道,通过sentry找到的

预期结果

没有异常

实际结果

我们遇到了两个星期以来的这个异常

_TypeError: Null check operator used on a null value
  File "framework.dart", line 5606, in StatefulElement.state
  File "framework.dart", line 4831, in Element.findAncestorStateOfType
  File "scaffold.dart", line 62, in _WcScaffoldState.didChangeDependencies
  File "framework.dart", line 5636, in StatefulElement._firstBuild
  File "framework.dart", line 5463, in ComponentElement.mount
  File "framework.dart", line 4340, in Element.inflateWidget
  File "framework.dart", line 3843, in Element.updateChild
  File "framework.dart", line 5512, in ComponentElement.performRebuild
  File "framework.dart", line 5203, in Element.rebuild
  File "framework.dart", line 5563, in StatelessElement.update
  File "framework.dart", line 3827, in Element.updateChild
  File "framework.dart", line 5512, in ComponentElement.performRebuild
  File "framework.dart", line 5650, in StatefulElement.performRebuild
  File "framework.dart", line 5203, in Element.rebuild
  File "framework.dart", line 5673, in StatefulElement.update
  File "framework.dart", line 3827, in Element.updateChild
  File "framework.dart", line 5512, in ComponentElement.performRebuild
  File "framework.dart", line 5650, in StatefulElement.performRebuild
  File "framework.dart", line 5203, in Element.rebuild
  File "framework.dart", line 5673, in StatefulElement.update
  File "framework.dart", line 3827, in Element.updateChild
  File "framework.dart", line 5512, in ComponentElement.performRebuild
  File "framework.dart", line 5650, in StatefulElement.performRebuild
  File "framework.dart", line 5203, in Element.rebuild
  File "framework.dart", line 2905, in BuildOwner.buildScope
  File "binding.dart", line 1136, in WidgetsBinding.drawFrame
  File "binding.dart", line 443, in RendererBinding._handlePersistentFrameCallback
  File "binding.dart", line 1392, in SchedulerBinding._invokeFrameCallback
  File "binding.dart", line 1313, in SchedulerBinding.handleDrawFrame
  File "binding.dart", line 1171, in SchedulerBinding._handleDrawFrame
  File "zone.dart", line 1399, in _rootRun
  File "zone.dart", line 1301, in _CustomZone.run
  File "zone.dart", line 1209, in _CustomZone.runGuarded
  File "hooks.dart", line 314, in _invoke
  File "platform_dispatcher.dart", line 419, in PlatformDispatcher._drawFrame
  File "hooks.dart", line 283, in _drawFrame

崩溃正好发生在这里

_state 如何在 didChangeDependencies 的调用中为null?

代码示例

代码示例

[Paste your code here]

截图或视频

截图/视频演示
[上传媒体在这里]

日志

日志

[Paste your logs here]

Flutter Doctor输出

Doctor输出

[√] Flutter (Channel stable, 3.22.0, on Microsoft Windows [Version 10.0.19045.4651], locale de-DE)
• Flutter version 3.22.0 on channel stable at C:\Users\escam\fvm\versions\3.22.0
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5dcb86f68f (10 weeks ago), 2024-05-09 07:39:20 -0500
• Engine revision f6344b75dc
• Dart version 3.4.0
• DevTools version 2.34.3

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at C:\Users\escam\AppData\Local\Android\sdk
• Platform android-34, build-tools 33.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.6.2)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.6.33723.286
• Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2022.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)

[√] VS Code, 64-bit edition (version 1.91.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.92.0

[√] Connected device (4 available)
• sdk gphone x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
• Windows (desktop)          • windows       • windows-x64    • Microsoft Windows [Version 10.0.19045.4651]
• Chrome (web)               • chrome        • web-javascript • Google Chrome 126.0.6478.127
• Edge (web)                 • edge          • web-javascript • Microsoft Edge 126.0.2592.102

[√] Network resources
• All expected network resources are available.
ryhaxcpt

ryhaxcpt1#

根据收到的报告和错误,保持问题开放。

相关问题