[Bug] Null check operator used on a null value
Hi there, I updated the package recently from pluto_grid: ^4.0.1 to pluto_grid: ^5.0.4 which has break change. After that, there may be an error as below: `---------- ERROR ---------- Null check operator used on a null value
------- STACK TRACE -------
#0 LayoutState.rightFrozenLeftOffset (package:pluto_grid/src/manager/state/layout_state.dart:318)
#1 PlutoGridState.updateState (package:pluto_grid/src/pluto_grid.dart:445)
#2 PlutoGridState.initState.
I can't reproduce it because the errors can't hit every time.
The code located to below code block during debugging:

Execution Environment
Flutter version
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [版本
10.0.19044.1826], locale zh-CN)
[√] Android toolchain - develop for Android devices (Android SDK version
30.0.3)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022
17.2.6)
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.69.2)
[√] Connected device (3 available)
Thank you.
It's hard to pinpoint the problem just from what you posted. Is the problem intermittent? Can you be more specific about what happens under what circumstances? It would be better if you attach sample code.
Hi @bosskmk , Thank you for quick response.
Yes, it is very diffcicult to figure out the cause from current situation.
It is intermittent, e.g. the first time or second time to load a new page, but not sure.
Yes, I will try to collect a reproduceable sample, it is hard too, since it is on the top of heritation. I tried your demo code on my local machine, it works well, so it is from my layout.
I suspect a size constraint(may be the width) is tighten(! check) and is hitted(or get the width before its parent lay out) in the version after 4.0.1. From the record, maxWidth is null.
Now I have to rollback to 4.0.1 and I will check it by remove the layout outside plutogrid and come back to you.
Thank you.
Can you test after modifying the /src/pluto_grid.dart file as follows?
I didn't upload a separate repository because you can easily edit it.
@override
void initState() {
_initStateManager();
_initKeyManager();
_initEventManager();
_initOnLoadedEvent();
_initSelectMode();
_initHeaderFooter();
_disposeList.add(() {
_gridFocusNode.dispose();
});
// WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
// updateState();
// });
// Comment out the above line and edit it as follows
WidgetsBinding.instance.endOfFrame.then((_) {
updateState();
});
super.initState();
}
Hi @bosskmk I tried your fix code but no luck.
Anyway, please leave it here and wait for my reproduceable sample, now, it is too hard to debug or fix it.
Thank you.
I had the same problem。
Hi @bosskmk , Thank you evaluating it and now I have a minimum example, hope you can reproduce it on your computer. The problem may be from the tab.
Please use the file as below to reproduce it. main.zip Thank you.
Hi @bosskmk , After I figured out the minimal example, a workround may be helpful:
LayoutBuilder(
builder: (context, constraint) {
if (constraint.maxWidth == 0) {
return Container();
}
return const PlutoGrid(
columns: [],
rows: [],
);
},
),
@shunsen You can have a try on this.
Thank you.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
@bosskmk This issue is still present so it should be reopened.
@henry2man I tried the above example codes, but no problem occurred. Tested on the latest version. Flutter 3.3.4 PlutoGrid 5.3.0
If you provide a version and steps or code to reproduce the problem, we will check it out.