mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Added scrollbar example (#75761)
This commit is contained in:
parent
40e3489254
commit
59ea6192c6
@ -34,7 +34,54 @@ const Duration _kScrollbarTimeToFade = Duration(milliseconds: 600);
|
||||
/// [showTrackOnHover]. The thickness of the track and scrollbar thumb will
|
||||
/// become larger when hovering, unless overridden by [hoverThickness].
|
||||
///
|
||||
// TODO(Piinks): Add code sample
|
||||
/// {@tool dartpad --template=stateless_widget_scaffold}
|
||||
/// This sample shows a [Scrollbar] that executes a fade animation as scrolling occurs.
|
||||
/// The Scrollbar will fade into view as the user scrolls, and fade out when scrolling stops.
|
||||
/// ```dart
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scrollbar(
|
||||
/// child: GridView.builder(
|
||||
/// itemCount: 120,
|
||||
/// gridDelegate:
|
||||
/// const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
|
||||
/// itemBuilder: (BuildContext context, int index) {
|
||||
/// return Center(
|
||||
/// child: Text('item $index'),
|
||||
/// );
|
||||
/// },
|
||||
/// ),
|
||||
/// );
|
||||
/// }
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
///
|
||||
/// {@tool dartpad --template=stateful_widget_scaffold}
|
||||
/// When isAlwaysShown is true, the scrollbar thumb will remain visible without the
|
||||
/// fade animation. This requires that a ScrollController is provided to controller,
|
||||
/// or that the PrimaryScrollController is available.
|
||||
/// ```dart
|
||||
/// final ScrollController _controllerOne = ScrollController();
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scrollbar(
|
||||
/// controller: _controllerOne,
|
||||
/// isAlwaysShown: true,
|
||||
/// child: GridView.builder(
|
||||
/// controller: _controllerOne,
|
||||
/// itemCount: 120,
|
||||
/// gridDelegate:
|
||||
/// const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
|
||||
/// itemBuilder: (BuildContext context, int index) {
|
||||
/// return Center(
|
||||
/// child: Text('item $index'),
|
||||
/// );
|
||||
/// },
|
||||
/// ),
|
||||
/// );
|
||||
/// }
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user