admin管理员组文章数量:1434914
The app I've developed is made to be run on Windows and made in flutter: it has been on production for more than a year and is running on probably around a hundred different computers on different customers, and everything works just fine.
But there's a single computer, with no outstanding detail to separate it from the others, on which my app simply doesn't work: it loads up but the GUI shows only the gray background that, if it were run in an IDE, would be replaced by the red background with the yellow text detailing the exception.
Nevertheless, I've managed to get the exception, and it contains very little information, and, to my woe, the exception is the worst one to look for on google:
Null check operator used on a null value
#0 Directionality.of (package:flutter/src/widgets/basic.dart:178)
#1 RichText.createRenderObject (package:flutter/src/widgets/basic.dart:5881)
#2 RenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6586)
#3 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:7042)
#4 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4468)
#5 Element.updateChild (package:flutter/src/widgets/framework.dart:3963)
#6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642)
#7 Element.rebuild (package:flutter/src/widgets/framework.dart:5333)
#8 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:5599)
#9 ComponentElement.mount (package:flutter/src/widgets/framework.dart:5593)
#10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4468)
#11 Element.updateChild (package:flutter/src/widgets/framework.dart:3957)
#12 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6907)
#13 Element.updateChild (package:flutter/src/widgets/framework.dart:3941)
#14 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642)
#15 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5780)
#16 Element.rebuild (package:flutter/src/widgets/framework.dart:5333)
#17 BuildScope._tryRebuild (package:flutter/src/widgets/framework.dart:2693)
#18 BuildScope._flushDirtyElements (package:flutter/src/widgets/framework.dart:2752)
#19 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:3048)
#20 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1162)
#21 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:468)
#22 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1397)
#23 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1318)
#24 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1176)
#28 _invoke (dart:ui/hooks.dart:314)
#29 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:419)
#30 _drawFrame (dart:ui/hooks.dart:283)
(elided 3 frames from dart:async)
The computer, as I said, seems pretty normal: Windows 11 version 24H2 build 26100.2033 on AMD Ryzen 5 6600H with Radeon Graphics, with no peculiar language installed or something that seems to be linked to the Directionality
widget that appears at the top of the stacktrace.
I'm not posting any code because, well, it is working just fine on countless other Windows 11 and 10 (and maybe also 7), so I think the issue is caused by something on that specific computer.
Could it be caused by some obscure windows setting? Anyone experienced something like this?
Just to be clear, I'll repeat: there is no missing !
in my code or anything that usually causes the Null check operator
exception. The stacktrace points to the original flutter code, not mine.
EDIT
This is the widget tree:
It should show a simple login page, with two username and password textfields inside a form, another textfield to display errors and a button to login.
The app I've developed is made to be run on Windows and made in flutter: it has been on production for more than a year and is running on probably around a hundred different computers on different customers, and everything works just fine.
But there's a single computer, with no outstanding detail to separate it from the others, on which my app simply doesn't work: it loads up but the GUI shows only the gray background that, if it were run in an IDE, would be replaced by the red background with the yellow text detailing the exception.
Nevertheless, I've managed to get the exception, and it contains very little information, and, to my woe, the exception is the worst one to look for on google:
Null check operator used on a null value
#0 Directionality.of (package:flutter/src/widgets/basic.dart:178)
#1 RichText.createRenderObject (package:flutter/src/widgets/basic.dart:5881)
#2 RenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6586)
#3 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:7042)
#4 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4468)
#5 Element.updateChild (package:flutter/src/widgets/framework.dart:3963)
#6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642)
#7 Element.rebuild (package:flutter/src/widgets/framework.dart:5333)
#8 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:5599)
#9 ComponentElement.mount (package:flutter/src/widgets/framework.dart:5593)
#10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4468)
#11 Element.updateChild (package:flutter/src/widgets/framework.dart:3957)
#12 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6907)
#13 Element.updateChild (package:flutter/src/widgets/framework.dart:3941)
#14 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642)
#15 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5780)
#16 Element.rebuild (package:flutter/src/widgets/framework.dart:5333)
#17 BuildScope._tryRebuild (package:flutter/src/widgets/framework.dart:2693)
#18 BuildScope._flushDirtyElements (package:flutter/src/widgets/framework.dart:2752)
#19 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:3048)
#20 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1162)
#21 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:468)
#22 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1397)
#23 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1318)
#24 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1176)
#28 _invoke (dart:ui/hooks.dart:314)
#29 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:419)
#30 _drawFrame (dart:ui/hooks.dart:283)
(elided 3 frames from dart:async)
The computer, as I said, seems pretty normal: Windows 11 version 24H2 build 26100.2033 on AMD Ryzen 5 6600H with Radeon Graphics, with no peculiar language installed or something that seems to be linked to the Directionality
widget that appears at the top of the stacktrace.
I'm not posting any code because, well, it is working just fine on countless other Windows 11 and 10 (and maybe also 7), so I think the issue is caused by something on that specific computer.
Could it be caused by some obscure windows setting? Anyone experienced something like this?
Just to be clear, I'll repeat: there is no missing !
in my code or anything that usually causes the Null check operator
exception. The stacktrace points to the original flutter code, not mine.
EDIT
This is the widget tree:
It should show a simple login page, with two username and password textfields inside a form, another textfield to display errors and a button to login.
- 1 need sample snippet of your widget tree to understand the issue – Md. Yeasin Sheikh Commented Nov 18, 2024 at 15:25
- @Md.YeasinSheikh added a screenshot of the tree from Android Studio inspector – il_boga Commented Nov 18, 2024 at 16:07
2 Answers
Reset to default 0It is hard to know but here some points:
I would start here. In this line: #1 RichText.createRenderObject we have this method
@override
RenderParagraph createRenderObject(BuildContext context) {
assert(textDirection != null || debugCheckHasDirectionality(context));
return RenderParagraph(text,
textAlign: textAlign,
textDirection: textDirection ?? Directionality.of(context),
softWrap: softWrap,
overflow: overflow,
textScaler: textScaler,
maxLines: maxLines,
strutStyle: strutStyle,
textWidthBasis: textWidthBasis,
textHeightBehavior: textHeightBehavior,
locale: locale ?? Localizations.maybeLocaleOf(context),
registrar: selectionRegistrar,
selectionColor: selectionColor,
);
}
And here #0 Directionality.of:
static TextDirection of(BuildContext context) {
assert(debugCheckHasDirectionality(context));
final Directionality widget = context.dependOnInheritedWidgetOfExactType<Directionality>()!;
return widget.textDirection;
}
And here debugCheckHasDirectionality: https://api.flutter.dev/flutter/widgets/debugCheckHasDirectionality.html
Do you have access of this computer, try to trace in debugCheckHasDirectionality.
Thanks everyone for your time, but I found the cause of the issue.
When I was adding the widget tree to the question, as I was asked, I noticed that somehow a FutureBuilder
had snuck out of the MaterialApp
: an issue perfectly consistent with the missing Directionality
widget that seemed to be the cause of the grey error screen.
I then pinpointed the FutureBuilder
and its Future
, and noticed that it could actually return a simple Text
widget that would end up being shown without the necessary support of MaterialApp
and the likes.
Today I managed to connect to that peculiar PC, and I installed a beta version that avoided showing an orphan Text
and, et voilà, the real error was shown in the GUI (which had nothing to do with Flutter and I already managed to solve).
So, thanks again for being my rubber duck.
本文标签: flutterNull check operator exception on a single computerStack Overflow
版权声明:本文标题:flutter - Null check operator exception on a single computer - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745613145a2666235.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论