Use case
I am currently developing a new feature in my business app using two_dimensional_scrollables package (v0.3.6). It works great for almost all the features and requirements I need. However, I have found an issue related to merged cells.
For example, my table has merged cells spanning 5 or 6 columns (these are not pinned columns). When I scroll the table horizontally and the first cell of the merged group becomes overlaid by a pinned column, it unmerges all the remaining cells. This is not the behavior I expected.
Can you help me with any ideas to avoid this issue?
Proposal
As described in my use case above, I want merged cells to remain intact (not "broken") when overlaid by pinned columns. Below is my sample code:
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:two_dimensional_scrollables/two_dimensional_scrollables.dart';
/// The class demonstrating merged cells in TableView.
class MergedTableExample extends StatefulWidget {
/// Creates a screen that shows a color palette in the TableView widget.
const MergedTableExample({super.key});
@override
State<MergedTableExample> createState() => _MergedTableExampleState();
}
class _MergedTableExampleState extends State<MergedTableExample> {
@override
Widget build(BuildContext context) {
final Size screenSize = MediaQuery.sizeOf(context);
return Scaffold(
body: Padding(
padding: EdgeInsets.symmetric(horizontal: screenSize.width * 0),
child: TableView.builder(
cellBuilder: _buildCell,
columnCount: 1000,
pinnedColumnCount: 1,
columnBuilder: _buildColumnSpan,
rowCount: 51,
rowBuilder: _buildRowSpan,
),
),
);
}
TableViewCell _buildCell(BuildContext context, TableVicinity vicinity) {
final int colorIndex = (vicinity.row / 3).floor();
final TextStyle style = TextStyle(
color: Colors.black,
fontSize: 18.0,
fontWeight: vicinity.column == 0 ? FontWeight.bold : null,
);
return TableViewCell(
rowMergeStart: vicinity.column == 0 ? colorIndex * 3 : null,
rowMergeSpan: vicinity.column == 0 ? 3 : null,
columnMergeStart: vicinity.column == 1 ? vicinity.column : null,
columnMergeSpan: vicinity.column == 1 ? 3 : null,
child: ColoredBox(
color: Colors.grey,
child: Center(child: Text('cell.name', style: style)),
),
);
}
TableSpan _buildColumnSpan(int index) {
return TableSpan(
extent: FixedTableSpanExtent(index == 0 ? 220 : 50),
foregroundDecoration: index == 0
? const TableSpanDecoration(
border: TableSpanBorder(
trailing: BorderSide(width: 5, color: Colors.white),
),
)
: null,
);
}
TableSpan _buildRowSpan(int index) {
return TableSpan(
extent: const FixedTableSpanExtent(120),
padding: index % 3 == 0 ? const TableSpanPadding(leading: 5.0) : null,
);
}
}
Use case
I am currently developing a new feature in my business app using two_dimensional_scrollables package (v0.3.6). It works great for almost all the features and requirements I need. However, I have found an issue related to merged cells.
For example, my table has merged cells spanning 5 or 6 columns (these are not pinned columns). When I scroll the table horizontally and the first cell of the merged group becomes overlaid by a pinned column, it unmerges all the remaining cells. This is not the behavior I expected.
Can you help me with any ideas to avoid this issue?
Proposal
As described in my use case above, I want merged cells to remain intact (not "broken") when overlaid by pinned columns. Below is my sample code: