diff --git a/CHANGELOG.md b/CHANGELOG.md index 608ee73..c9f495e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [2.0.2] - 2024-03-29 #### [@RichiB20](https://github.com/RichiB20) - Fixed vertical Scrollbar and added horizontal Scrollbar. +- Added `trackVisibilityScrollbar` parameter. - Fixed table size. ## [2.0.1] - 2023-09-04 diff --git a/example/lib/main.dart b/example/lib/main.dart index 769e749..0e52eae 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -132,6 +132,7 @@ class _MyHomePageState extends State { scrollShadowColor: accentColor, rows: rows, visibleScrollbar: true, + trackVisibilityScrollbar: true, ); } @@ -201,6 +202,7 @@ class _MyHomePageState extends State { firstColumnWidth: 250, scrollShadowColor: accentColor, visibleScrollbar: true, + trackVisibilityScrollbar: true, ); } diff --git a/lib/src/class/controller.dart b/lib/src/class/controller.dart index cc7af3e..916e097 100644 --- a/lib/src/class/controller.dart +++ b/lib/src/class/controller.dart @@ -100,6 +100,18 @@ class ExpandableTableController extends ChangeNotifier { notifyListeners(); } + bool _trackVisibilityScrollbar = false; + + /// [trackVisibilityScrollbar] indicates that the scrollbar track should be visible. + /// + /// Default: [false] + bool get trackVisibilityScrollbar => _trackVisibilityScrollbar; + + set trackVisibilityScrollbar(bool value) { + _trackVisibilityScrollbar = value; + notifyListeners(); + } + /// [duration] determines duration rendered animation of Rows/Columns expansion. /// /// Default: [500ms] @@ -148,6 +160,7 @@ class ExpandableTableController extends ChangeNotifier { required List headers, required List rows, bool visibleScrollbar = false, + bool trackVisibilityScrollbar = false, this.duration = const Duration(milliseconds: 500), this.curve = Curves.fastOutSlowIn, this.scrollShadowDuration = const Duration(milliseconds: 500), @@ -168,6 +181,7 @@ class ExpandableTableController extends ChangeNotifier { _headers = headers; _rows = rows; _visibleScrollbar = visibleScrollbar; + _trackVisibilityScrollbar = trackVisibilityScrollbar; _addHeadersListener(); _addRowsListener(); } diff --git a/lib/src/widget/table.dart b/lib/src/widget/table.dart index 29181d0..bd049a6 100644 --- a/lib/src/widget/table.dart +++ b/lib/src/widget/table.dart @@ -86,6 +86,11 @@ class ExpandableTable extends StatefulWidget { /// Default: [false] final bool visibleScrollbar; + /// [trackVisibilityScrollbar] indicates that the scrollbar track should be visible. + /// + /// Default: [false] + final bool trackVisibilityScrollbar; + /// [controller] specifies the external controller of the table, allows /// you to dynamically manage the data in the table externally. /// Do not use if [firstHeaderCell], [headers] and [rows] are passed @@ -123,6 +128,7 @@ class ExpandableTable extends StatefulWidget { this.scrollShadowColor = Colors.transparent, this.scrollShadowSize = 10, this.visibleScrollbar = false, + this.trackVisibilityScrollbar = false, }) : assert((firstHeaderCell != null && rows != null && headers != null) || controller != null); @@ -169,6 +175,7 @@ class _ExpandableTableState extends State { defaultsRowHeight: widget.defaultsRowHeight, headerHeight: widget.headerHeight, visibleScrollbar: widget.visibleScrollbar, + trackVisibilityScrollbar: widget.trackVisibilityScrollbar, ), builder: (context, child) => const InternalTable(), ); diff --git a/lib/src/widget_internal/table.dart b/lib/src/widget_internal/table.dart index 35a3e18..65c6015 100644 --- a/lib/src/widget_internal/table.dart +++ b/lib/src/widget_internal/table.dart @@ -180,11 +180,11 @@ class InternalTableState extends State { ? Scrollbar( controller: _horizontalBodyController, thumbVisibility: true, - trackVisibility: true, + trackVisibility: data.trackVisibilityScrollbar, child: Scrollbar( controller: _restColumnsController, thumbVisibility: true, - trackVisibility: true, + trackVisibility: data.trackVisibilityScrollbar, notificationPredicate: (notification) => notification.depth >= 0, child: child,