flutter 我得到这个错误,当我尝试启动配置文件屏幕

eit6fx6z  于 2023-04-13  发布在  Flutter
关注(0)|答案(2)|浏览(134)

========小部件库捕获到异常============================================================
在构建StreamBuilder〈QuerySnapshot〈Object?〉〉(dirty,dependencies:[_InheritedProviderScope〈DataManagerProvider?〉],状态:_StreamBuilderBaseState〈QuerySnapshot〈Object?〉,AsyncSnapshot〈QuerySnapshot〈Object?〉〉〉#92f1f):LateInitializationError:字段“photographerProfile”尚未初始化。
导致错误的相关小部件为:
StreamBuilder〈QuerySnapshot〈Object?〉〉StreamBuilder:file:///C:/Users/RANGO/StudioProjects/photography/lib/screens/photographer/photographer_dashboard.dart:101:18
当抛出异常时,这是堆栈:
#0 DataManagerProvider.photographerProfile(package:photography/data%20manager/data_manager.dart)
#1 DataManagerProvider.getPhotographerProfile(package:photography/data%20manager/data_manager.dart:54:51)
#2 _PhotographerDashboardState.build..(package:photography/screens/photographer/photographer_dashboard.dart:107:24)
#3StreamBuilder.build(package:flutter/src/widgets/async.dart:444:81)
#4 _StreamBuilderBaseState.build(package:flutter/src/widgets/async.dart:124:48)
#5StatefulElement.build(软件包:flutter/源代码/小部件/框架。dart:5080:27)
#6 ComponentElement.performRebuild(package:flutter/src/widgets/framework.dart:4968:15)
#7 StatefulElement.performRebuild(package:flutter/src/widgets/framework.dart:5133:11)
#8 Element.rebuild(package:flutter/src/widgets/framework.dart:4690:5)

r7s23pms

r7s23pms1#

如果您能添加代码,那就太好了,但就我所见,您正在尝试使用photographerProfile而不初始化它,因此您需要在使用它之前初始化该值。

cwtwac6a

cwtwac6a2#

文件中有一个变量:../lib/screens/photographer/photographer_dashboard.dart
第101行,第18列
late photographerProfile...
这是用来作为一个后期初始化,但使用没有被初始化第一.目前,flutter有没有办法检查,如果一个变量已被初始化,所以也许你可以使它空代替?

相关问题