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.
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.