零检查操作员用于空值:相关引起错误的小部件是custombottombar
我是新手的颤抖。我得到了该错误的null检查操作员,该操作员在空值错误上使用。但是我无法解决。这是第二个例外的地方:“相关引起错误的小部件是 消费者“发生:
@override
Widget build(BuildContext context) {
return Positioned(
bottom: ScreenUtil().setSp(74),
child: SizedBox(
width: ScreenUtil().setSp(67),
height: ScreenUtil().setSp(67),
child: Consumer<AnimationProvider>(
builder: (_, AnimationProvider animate, __) { // AnimationProvider
return FloatingActionButton(
backgroundColor: CustomColor.bluelight,
onPressed:
animate.flareAnimationCompleted
? () async => await _handleAnimation(context)
: () {},
child: buildFlareActor(animate));
},
),
),
);
}
建造者:
final Widget Function(
BuildContext context,
T value,
Widget? child,
) builder;
这是调试器输出:
wide库捕获的例外════════════════════════ null
检查运算符在零值上使用 相关引起错误的小部件是CustomBottombar ══════════════════════════════════════════════════ ════════════════
小部件图书馆捕获的例外 null
检查运算符在零值上使用 相关引起错误的小部件是消费者动画制作者
═════════════════════════════════════════ ══════════════════════════════
请帮助我。谢谢
Im new to Flutter. I got this error Null check operator used on a null value error. but I could not solve it. This is the place where the second exception "The relevant error-causing widget was
Consumer" occurs:
@override
Widget build(BuildContext context) {
return Positioned(
bottom: ScreenUtil().setSp(74),
child: SizedBox(
width: ScreenUtil().setSp(67),
height: ScreenUtil().setSp(67),
child: Consumer<AnimationProvider>(
builder: (_, AnimationProvider animate, __) { // AnimationProvider
return FloatingActionButton(
backgroundColor: CustomColor.bluelight,
onPressed:
animate.flareAnimationCompleted
? () async => await _handleAnimation(context)
: () {},
child: buildFlareActor(animate));
},
),
),
);
}
the builder:
final Widget Function(
BuildContext context,
T value,
Widget? child,
) builder;
This is the debugger output:
════════ Exception caught by widgets library ══════════════════════════
Null check operator used on a null value
The relevant error-causing widget was CustomBottomBar
═══════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ══════════════════════════
Null check operator used on a null value
The relevant error-causing widget was Consumer AnimationProvider
═══════════════════════════════════════════════════════════════════════
Please help me. Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在遇到此错误,因为您使用的是Null检查操作员“!”在已经无效的变量上。解决方案是正确初始化这些变量或在未初始化时避免调用它们。搜索您添加的“代码”部分“!”操作员,看看这些变量是否适当初始化。如果您需要更多帮助,请编辑您的问题,以包括您面对此错误的整个代码。
You are getting this error because you are using a null check operator "!" on a variable that is already null. The solution is to properly initialize those variables or to avoid calling them when they're not initialized. Search for parts of code where you have added "!" operator and see if those variables are properly initialized or not. If you want more help, please edit your question to include the entire code where you're facing this error.
您正在遇到此错误,因为您正在使用null检查操作员(!)上的空值。因此,请确认您所使用的变量是否正确分配了您的空检查操作员。
另一个解决方案是您可以将默认值初始化为变量
ex: -
int age = 10;
或者您可以使用年龄? 20而不是!
you are getting this error because you are using the null check operator(!) on a null value. So get confirm your null check operator used variable is assign properly or not.
The Other Solution is you can initialize default value to the your variable
ex:-
int age=10;
or you can use age ?? 20 instead of !age