@@ -82,6 +82,11 @@ class DataGrid extends StatefulWidget
82
82
controller.dataRowHeight = Utils .optionalDouble (val),
83
83
'headingRowHeight' : (val) =>
84
84
controller.headingRowHeight = Utils .optionalDouble (val),
85
+ 'scrollbarBehaviour' : (val) =>
86
+ controller.scrollbarBehaviour =
87
+ Utils .getEnum <ScrollbarBehaviour >(val, ScrollbarBehaviour .values),
88
+ 'thumbThickness' : (val) =>
89
+ controller.thumbThickness = Utils .optionalDouble (val),
85
90
'columnSpacing' : (val) =>
86
91
controller.columnSpacing = Utils .optionalDouble (val),
87
92
'dividerThickness' : (val) =>
@@ -184,7 +189,9 @@ class DataGridController extends BoxController {
184
189
GenericTextController ? headingTextController;
185
190
double ? dataRowHeight;
186
191
double ? headingRowHeight;
192
+ ScrollbarBehaviour ? scrollbarBehaviour;
187
193
double ? columnSpacing;
194
+ double ? thumbThickness;
188
195
GenericTextController ? dataTextController;
189
196
double ? dividerThickness;
190
197
TableBorder border = const TableBorder ();
@@ -268,6 +275,7 @@ class DataGridState extends EWidgetState<DataGrid>
268
275
@override
269
276
Widget buildWidget (BuildContext context) {
270
277
ScopeManager ? scopeManager = DataScopeWidget .getScope (context);
278
+ final ScrollController _scrollController = ScrollController ();
271
279
if (scopeManager == null ) {
272
280
throw Exception (
273
281
'scopeManager is null in the DataGrid.buildWidget method. This is unexpected. DataGrid.id=${widget .id }' );
@@ -311,13 +319,17 @@ class DataGridState extends EWidgetState<DataGrid>
311
319
);
312
320
return SingleChildScrollView (
313
321
scrollDirection: Axis .vertical,
314
- child: SingleChildScrollView (
315
- scrollDirection: Axis .horizontal,
316
322
317
- // DataTable requires all children to report their intrinsic height.
318
- // Some widgets don't like that so we expose this so the widgets
319
- // can react accordingly
320
- child: RequiresChildWithIntrinsicDimension (child: grid),
323
+ child: RawScrollbar (
324
+ thickness: widget.controller.thumbThickness,
325
+ controller: _scrollController,
326
+ thumbVisibility: widget.controller.scrollbarBehaviour == ScrollbarBehaviour .static ,
327
+ trackVisibility: widget.controller.scrollbarBehaviour == ScrollbarBehaviour .static ,
328
+ child: SingleChildScrollView (
329
+ scrollDirection: Axis .horizontal,
330
+ controller: _scrollController,
331
+ child: RequiresChildWithIntrinsicDimension (child: grid),
332
+ ),
321
333
),
322
334
);
323
335
}
@@ -407,7 +419,7 @@ class DataGridState extends EWidgetState<DataGrid>
407
419
if (kDebugMode) {
408
420
print (
409
421
'Number of DataGrid columns must be equal to the number of cells in each row. Number of DataGrid columns is ${_columns .length } '
410
- 'while number of cells in the row is ${cells .length }. We will try to match them to be the same' );
422
+ 'while number of cells in the row is ${cells .length }. We will try to match them to be the same' );
411
423
}
412
424
if (_columns.length > cells.length) {
413
425
int diff = _columns.length - cells.length;
@@ -503,3 +515,7 @@ class DataGridState extends EWidgetState<DataGrid>
503
515
}
504
516
}
505
517
}
518
+ enum ScrollbarBehaviour {
519
+ static ,
520
+ fade
521
+ }
0 commit comments