isAlwaysShown property Null safety
Deprecated('Use thumbVisibility instead. ' 'This feature was deprecated after v2.9.0-1.0.pre.')">@Deprecated('Use thumbVisibility instead. ' 'This feature was deprecated after v2.9.0-1.0.pre.')final
Indicates that the scrollbar thumb should be visible, even when a scroll is not underway.
When false, the scrollbar will be shown during scrolling and will fade out otherwise.
When true, the scrollbar will always be visible and never fade out. This requires that the Scrollbar can access the ScrollController of the associated Scrollable widget. This can either be the provided controller, or the PrimaryScrollController of the current context.
- When providing a controller, the same ScrollController must also be provided to the associated Scrollable widget.
- The PrimaryScrollController is used by default for a ScrollView that has not been provided a ScrollController and that has an Axis.vertical ScrollDirection. This automatic behavior does not apply to those with a ScrollDirection of Axis.horizontal. To explicitly use the PrimaryScrollController, set ScrollView.primary to true.
Defaults to false when null.
final ScrollController controllerOne = ScrollController();
final ScrollController controllerTwo = ScrollController();
Widget build(BuildContext context) {
return Column(
children: <Widget>[
SizedBox(
height: 200,
child: Scrollbar(
thumbVisibility: true,
controller: controllerOne,
child: ListView.builder(
controller: controllerOne,
itemCount: 120,
itemBuilder: (BuildContext context, int index) {
return Text('item $index');
},
),
),
),
SizedBox(
height: 200,
child: CupertinoScrollbar(
thumbVisibility: true,
controller: controllerTwo,
child: SingleChildScrollView(
controller: controllerTwo,
child: const SizedBox(
height: 2000,
width: 500,
child: Placeholder(),
),
),
),
),
],
);
}
See also:
- RawScrollbarState.showScrollbar, an overridable getter which uses this value to override the default behavior.
- ScrollView.primary, which indicates whether the ScrollView is the primary scroll view associated with the parent PrimaryScrollController.
- PrimaryScrollController, which associates a ScrollController with a subtree.
This is deprecated, thumbVisibility should be used instead.
Implementation
@Deprecated(
'Use thumbVisibility instead. '
'This feature was deprecated after v2.9.0-1.0.pre.',
)
final bool? isAlwaysShown;