-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# The ListWheelScrollView Widget | ||
|
||
Did you know? | ||
|
||
If you need to select between a small list of values but have limited vertical space, you can use a `ListWheelScrollView`. 🎯 | ||
|
||
Pro Tip: use `FixedExtentScrollPhysics` to snap to the nearest item when the user stops scrolling. 👍 | ||
|
||
![](220.gif) | ||
|
||
<!-- | ||
ListWheelScrollView.useDelegate( | ||
// Size of each item in the main axis | ||
itemExtent: 100, | ||
// Ratio between the diameter and the viewport height | ||
diameterRatio: 1.5, | ||
// Controller to control the scroll position | ||
controller: FixedExtentScrollController( | ||
initialItem: selectedIndex, | ||
), | ||
// Snap to nearest item when the user stops scrolling | ||
physics: const FixedExtentScrollPhysics(), | ||
// Callback when the user selects an item | ||
onSelectedItemChanged: onSelectedItemChanged, | ||
// List of items to display | ||
childDelegate: ListWheelChildBuilderDelegate( | ||
childCount: timezones.length, | ||
builder: (context, index) => TimeZoneDisplayCard( | ||
timezone: timezones[index], | ||
isSelected: selectedIndex == index, | ||
), | ||
), | ||
) | ||
--> | ||
|
||
How to use: | ||
|
||
- call the regular `ListWheelScrollView` constructor and pass a list of children. | ||
- call `ListWheelScrollView.useDelegate` and pass a `ListWheelChildDelegate`. | ||
|
||
For all the details, check the official docs: | ||
|
||
- [ListWheelScrollView class](https://api.flutter.dev/flutter/widgets/ListWheelScrollView-class.html) | ||
|
||
|
||
--- | ||
|
||
| Previous | Next | | ||
| -------- | ---- | | ||
| [Color API Deprecations in Flutter 3.27](../0219-color-deprecations-flutter-3.27/index.md) | | | ||
|
||
|
||
<!-- TWITTER|https://x.com/biz84/status/1870061289114087814 --> | ||
<!-- LINKEDIN|https://www.linkedin.com/posts/andreabizzotto_did-you-know-if-you-need-to-select-between-activity-7275827511219945472-cYEH --> | ||
<!-- BLUESKY|https://bsky.app/profile/codewithandrea.com/post/3ldqaaejlx22e --> |