Repository navigation
[two_dimensional_scrollables] Table crashes when focusing outside of the table while focused text field is not in the view. #137112
Copy link
Copy link
Closed
flutter/packages
#11376Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolefound in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16Found to occur in 3.16has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: two_dimensional_scrollablesIssues pertaining to the two_dimensional_scrollables packageIssues pertaining to the two_dimensional_scrollables packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
Only tested in windows and web. Both has the same problem.
- First select a TextField in the table.
- Scroll until it disappears from the view, without unfocusing it.
- Select an another TextField outside of the table.
- Scroll back and the table crashes.
Expected results
The expected behavior would be that the element with the primary focus would unfocus when going out of the view.
Actual results
Crash if i focus the textfield outside of the table. If i don't focus anything else and just return to previous scroll position the textfield remains in (or regains) focus, which is weird but maybe it's a separate issue.
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:two_dimensional_scrollables/two_dimensional_scrollables.dart';
void main() {
runApp(const TableExample());
}
class TableExample extends StatefulWidget {
const TableExample({super.key});
@override
State<TableExample> createState() => _TableExampleState();
}
class _TableExampleState extends State<TableExample> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Table Example'),
),
body: Column(
children: [
const TextField(),
Expanded(
child: TableView.builder(
cellBuilder: _buildCell,
columnCount: 20,
columnBuilder: _buildColumnSpan,
rowCount: 40,
rowBuilder: _buildRowSpan,
),
),
],
),
),
);
}
Widget _buildCell(BuildContext context, TableVicinity vicinity) {
return const Center(
child: TextField(),
);
}
TableSpan _buildColumnSpan(int index) {
return const TableSpan(
foregroundDecoration: TableSpanDecoration(
border: TableSpanBorder(
trailing: BorderSide(),
),
),
extent: FixedTableSpanExtent(100),
);
}
TableSpan _buildRowSpan(int index) {
return TableSpan(
backgroundDecoration: TableSpanDecoration(
color: index.isEven ? Colors.purple[100] : null,
border: const TableSpanBorder(
trailing: BorderSide(
width: 3,
),
),
),
extent: const FixedTableSpanExtent(50),
);
}
}
Screenshots or Video
Screenshots / Video demonstration
Logs
Logs
======== Exception caught by rendering library =====================================================
The following assertion was thrown during performLayout():
Expected to re-use an element at (row: 5, column: 6), but none was found.
'package:flutter/src/widgets/two_dimensional_viewport.dart':
Failed assertion: line 346 pos 7: 'elementToReuse != null'
Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.yml
When the exception was thrown, this was the stack:
#2 _TwoDimensionalViewportElement._reuseChild (package:flutter/src/widgets/two_dimensional_viewport.dart:346:7)
#3 RenderTwoDimensionalViewport.buildOrObtainChildFor (package:flutter/src/widgets/two_dimensional_viewport.dart:1431:21)
#4 RenderTableViewport._layoutCells (package:two_dimensional_scrollables/src/table_view/table.dart:680:33)
#5 RenderTableViewport.layoutChildSequence (package:two_dimensional_scrollables/src/table_view/table.dart:655:7)
#6 RenderTwoDimensionalViewport.performLayout (package:flutter/src/widgets/two_dimensional_viewport.dart:1252:5)
#7 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2385:7)
#8 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1025:18)
#9 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1038:15)
#10 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:591:23)
#11 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:986:13)
#12 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:457:5)
#13 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1325:15)
#14 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1255:9)
#15 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1113:5)
#16 _invoke (dart:ui/hooks.dart:312:13)
#17 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:383:5)
#18 _drawFrame (dart:ui/hooks.dart:283:31)
(elided 2 frames from class _AssertionError)
The following RenderObject was being processed when the exception was fired: RenderTableViewport#29598 NEEDS-LAYOUT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(0.0<=w<=1264.0, h=577.0)
... layer: OffsetLayer#8ceef
======== Exception caught by rendering library =====================================================
The following _TypeError was thrown during performLayout():
Null check operator used on a null value
When the exception was thrown, this was the stack:
#0 RenderTableViewport.parentDataOf (package:two_dimensional_scrollables/src/table_view/table.dart:325:23)
#1 RenderTwoDimensionalViewport.performLayout.<anonymous closure>.<anonymous closure> (package:flutter/src/widgets/two_dimensional_viewport.dart:1264:17)
#2 WhereIterator.moveNext (dart:_internal/iterable.dart:451:13)
#3 Iterable.isEmpty (dart:core/iterable.dart:540:33)
#4 RenderTwoDimensionalViewport.performLayout.<anonymous closure> (package:flutter/src/widgets/two_dimensional_viewport.dart:1265:10)
#5 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:2657:59)
#6 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:1071:15)
#7 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:2657:14)
#8 RenderTwoDimensionalViewport.performLayout (package:flutter/src/widgets/two_dimensional_viewport.dart:1258:5)
#9 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2385:7)
#10 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1025:18)
#11 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1038:15)
#12 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:591:23)
#13 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:986:13)
#14 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:457:5)
#15 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1325:15)
#16 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1255:9)
#17 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1113:5)
#18 _invoke (dart:ui/hooks.dart:312:13)
#19 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:383:5)
#20 _drawFrame (dart:ui/hooks.dart:283:31)
The following RenderObject was being processed when the exception was fired: RenderTableViewport#91098 NEEDS-LAYOUT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(0.0<=w<=1264.0, h=577.0)
... layer: OffsetLayer#932b2
... engine layer: OffsetEngineLayer#afe90
... handles: 2
... offset: Offset(0.0, 104.0)
... size: Size(1264.0, 577.0)
RenderObject: RenderTableViewport#91098 NEEDS-LAYOUT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: <none> (can use size)
constraints: BoxConstraints(0.0<=w<=1264.0, h=577.0)
layer: OffsetLayer#932b2
engine layer: OffsetEngineLayer#afe90
handles: 2
offset: Offset(0.0, 104.0)
size: Size(1264.0, 577.0
Flutter Doctor output
Doctor output
[√] Flutter (Channel beta, 3.16.0-0.3.pre, on Microsoft Windows [Version 10.0.22621.2428], locale en-US)
• Flutter version 3.16.0-0.3.pre on channel beta at C:\dev\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 476aa717cd (4 days ago), 2023-10-19 20:10:52 -0500
• Engine revision 91cde06da0
• Dart version 3.2.0 (build 3.2.0-210.3.beta)
• DevTools version 2.28.1
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at C:\Users\David\AppData\Local\Android\sdk
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.5.3)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
• Visual Studio Build Tools 2022 version 17.5.33516.290
• Windows 10 SDK version 10.0.22000.0
[√] Android Studio (version 2022.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-9505619)
[√] IntelliJ IDEA Ultimate Edition (version 2023.1)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.4
• Flutter plugin version 73.0.4
• Dart plugin version 231.8109.91
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.2428]
• Chrome (web) • chrome • web-javascript • Google Chrome 118.0.5993.89
• Edge (web) • edge • web-javascript • Microsoft Edge 118.0.2088.61
[√] Network resources
• All expected network resources are available.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolefound in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16Found to occur in 3.16has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: two_dimensional_scrollablesIssues pertaining to the two_dimensional_scrollables packageIssues pertaining to the two_dimensional_scrollables packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Type
Projects
- StatusShow more project fieldsDone
Activity
[-][two_dimensional_scrollables] Table crashes when focusing [/-][+][two_dimensional_scrollables] Table crashes when focusing outside of the table while focused text field is not in the view.[/+]Elixell commentedon Oct 24, 2023
@Piinks
darshankawar commentedon Oct 24, 2023
Thanks for the report. Following steps to replicate on latest master and stable versions, I seem to be getting different error as shared below upon running on mobile, web and desktop.
error console log
stable, master flutter doctor -v
Piinks commentedon Oct 26, 2023
I think this is fixed by #135182, but will need to check when it reaches the stable branch
[two_dimensional_scrollables] Add regression test (flutter#11376)
github-actions commentedon Apr 10, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.[two_dimensional_scrollables] Add regression test (flutter#11376)