Description
Bug description
When the grid is in a widget that can be vertically resized, if the widget height changes as the grid is scrolled all the way down, the top rows will get cut off.
Steps to reproduce
Create a test app with a resizable widget which contains the grid
Code sample
import 'package:flutter/material.dart';
import 'package:sync_fusion_test/horizontal_split_view.dart';
import 'package:syncfusion_flutter_datagrid/datagrid.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: HorizontalSplitView(top: DataGridScreen(), bottom: Container()),
),
);
}
}
class Employee {
Employee(this.id, this.name, this.designation, this.salary);
final int id;
final String name;
final String designation;
final double salary;
}
class EmployeeDataSource extends DataGridSource {
EmployeeDataSource(this.employees) {
buildDataGridRows();
}
List employees = [];
List dataGridRows = [];
void buildDataGridRows() {
dataGridRows =
employees.map((employee) {
return DataGridRow(
cells: [
DataGridCell(columnName: 'ID', value: employee.id),
DataGridCell(columnName: 'Name', value: employee.name),
DataGridCell(
columnName: 'Designation',
value: employee.designation,
),
DataGridCell(
columnName: 'Salary',
value: employee.salary,
),
],
);
}).toList();
}
@OverRide
List get rows => dataGridRows;
@OverRide
DataGridRowAdapter? buildRow(DataGridRow row) {
return DataGridRowAdapter(
cells:
row.getCells().map((dataCell) {
return Container(
alignment: Alignment.center,
padding: const EdgeInsets.all(8.0),
child: Text(dataCell.value.toString()),
);
}).toList(),
);
}
}
class DataGridScreen extends StatefulWidget {
const DataGridScreen({super.key});
@OverRide
State createState() => _DataGridScreenState();
}
class _DataGridScreenState extends State {
late EmployeeDataSource _employeeDataSource;
@OverRide
void initState() {
super.initState();
final List employees = List.generate(
20,
(index) => Employee(
1000 + index,
'Employé $index',
index % 2 == 0 ? 'Développeur' : 'Designer',
30000 + index * 1000.0,
),
);
_employeeDataSource = EmployeeDataSource(employees);
}
@OverRide
Widget build(BuildContext context) {
return SfDataGrid(
source: _employeeDataSource,
columns: [
GridColumn(columnName: 'ID', label: const Center(child: Text('ID'))),
GridColumn(columnName: 'Name', label: const Center(child: Text('Nom'))),
GridColumn(
columnName: 'Designation',
label: const Center(child: Text('Poste')),
),
GridColumn(
columnName: 'Salary',
label: const Center(child: Text('Salaire')),
),
],
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
class HorizontalSplitView extends HookWidget {
const HorizontalSplitView({
super.key,
required this.top,
required this.bottom,
this.initialSplitRatio = 0.5,
this.initiallyCollapsed = false,
this.minSplitRatio = 0.0,
this.maxSplitRatio = 1.0,
this.minBottomHeight = 100,
this.onSavePreferences,
this.preferences,
}) : assert(initialSplitRatio >= 0),
assert(initialSplitRatio <= 1);
final Widget top;
final Widget bottom;
final double initialSplitRatio;
final double minSplitRatio;
final double maxSplitRatio;
final double minBottomHeight;
final bool initiallyCollapsed;
final void Function(String)? onSavePreferences;
final String? preferences;
@OverRide
Widget build(BuildContext context) {
final splitRatio = useState(initialSplitRatio);
return LayoutBuilder(
builder: (context, constraints) {
final maxHeight = constraints.maxHeight;
final topHeight = splitRatio.value * maxHeight;
final bottomHeight = maxHeight - topHeight - 28;
return Column(
children: [
SizedBox(height: topHeight, child: top),
GestureDetector(
behavior: HitTestBehavior.translucent,
onVerticalDragUpdate: (details) {
final newTopHeight = topHeight + details.delta.dy;
final newRatio = newTopHeight / maxHeight;
if (newRatio >= minSplitRatio && newRatio <= maxSplitRatio) {
splitRatio.value = newRatio;
}
},
child: MouseRegion(
cursor: SystemMouseCursors.resizeUpDown,
child: Container(
color: Colors.transparent,
height: 28,
child: const Center(child: Divider(thickness: 2)),
),
),
),
SizedBox(
height: bottomHeight < minBottomHeight ? 0 : bottomHeight,
child: bottom,
),
],
);
},
);
}
}
Screenshots or Video
Stack Traces
.
On which target platforms have you observed this bug?
Windows
Flutter Doctor output
.