Skip to content

Commit 5af38d4

Browse files
sfshaza2parlough
andauthored
Add Scrolling intro page (#9068)
This removes the Slivers page from the Advanced UI section into its own Scrolling section. We will also be adding scrolling recipes to the sidebar of this section. The intro page kind of grew to be longer than I planned... This also adds a tooling error to the common errors page. Fixes #9064 cc @Piinks @parlough --------- Co-authored-by: Parker Lougheed <[email protected]>
1 parent 891e547 commit 5af38d4

File tree

5 files changed

+126
-14
lines changed

5 files changed

+126
-14
lines changed

firebase.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
{ "source": "/ios-release", "destination": "/deployment/ios", "type": 301 },
6363
{ "source": "/jobs/**", "destination": "/jobs", "type": 301 },
6464
{ "source": "/json", "destination": "/data-and-backend/json", "type": 301 },
65+
{ "source": "/ui/advanced/slivers", "destination": "/ui/scrolling/slivers", "type": 301 },
6566
{ "source": "/ui/layout/box-constraints", "destination": "/ui/layout/constraints#unbounded", "type": 301 },
6667
{ "source": "/networking", "destination": "/data-and-backend/networking", "type": 301 },
6768
{ "source": "/overview", "destination": "/resources/architectural-overview", "type": 301 },

src/_data/sidenav.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@
102102
permalink: /ui/animations/hero-animations
103103
- title: Staggered animations
104104
permalink: /ui/animations/staggered-animations
105+
- title: Scrolling
106+
permalink: /ui/scrolling
107+
children:
108+
- title: Introduction
109+
permalink: /ui/scrolling
110+
match-page-url-exactly: true
111+
- title: Slivers
112+
permalink: /ui/scrolling/slivers
105113
- title: Advanced UI
106114
permalink: /ui/advanced
107115
children:
@@ -115,8 +123,6 @@
115123
permalink: /ui/advanced/gestures
116124
- title: Shaders
117125
permalink: /ui/advanced/shaders
118-
- title: Slivers
119-
permalink: /ui/advanced/slivers
120126
- title: Widget catalog
121127
permalink: /ui/widgets
122128

src/testing/common-errors.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ future revisions, and your contributions are welcomed.
1515
Feel free to [open an issue][] or [submit a pull request][] to
1616
make this page more useful to you and the Flutter community.
1717

18-
{{site.alert.important}}
19-
You might be directed to this page if the
20-
framework detects a problem involving box constraints.
21-
For a deeper look into Flutter's box constraints,
22-
check out [Understanding constraints][].
23-
{{site.alert.end}}
24-
25-
[Understanding constraints]: {{site.url}}/ui/layout/constraints
26-
2718
[open an issue]: {{site.github}}/flutter/website/issues/new/choose
2819
[submit a pull request]: {{site.github}}/flutter/website/pulls
2920

@@ -148,6 +139,7 @@ The resources linked below provide further information about this error.
148139
[its source code]: {{site.repo.flutter}}/blob/c8e42b47f5ea8b5ff7bf2f2b0a2a8e765f1aa51d/packages/flutter/lib/src/widgets/basic.dart#L5166-L5174
149140
[flexible-video]: ({{site.youtube-site}}/watch?v=CI7x0mAZiY0)
150141
[medium-article]: {{site.flutter-medium}}/how-to-debug-layout-issues-with-the-flutter-inspector-87460a7b9db#738b
142+
[Understanding constraints]: {{site.url}}/ui/layout/constraints
151143

152144
## ‘RenderBox was not laid out’
153145

@@ -498,6 +490,23 @@ class FirstScreen extends StatelessWidget {
498490
}
499491
```
500492

493+
## `The ScrollController is attached to multiple scroll views`
494+
495+
This error can occur when multiple scrolling
496+
widgets (such as `ListView`) appear on the
497+
screen at the same time. It's more likely for
498+
this error to occur on a web or desktop app,
499+
than a mobile app since it's rare to encounter
500+
this scenario on mobile.
501+
502+
For more information and to learn how to fix,
503+
check out the following video on
504+
[`PrimaryScrollController`][controller-video]:
505+
506+
[controller-video]: <iframe width="560" height="315" src="https://www.youtube.com/embed/33_0ABjFJUU" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>`
507+
508+
[`PrimaryScrollController`]: {{site.api}}/flutter/widgets/PrimaryScrollController-class.html
509+
501510
## References
502511

503512
To learn more about how to debug errors,

src/ui/scrolling/index.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
title: Scrolling
3+
description: Overview of Flutter's scrolling support
4+
---
5+
6+
Flutter has many built-in widgets that automatically
7+
scroll and also offers a variety of widgets
8+
that you can customize to create specific scrolling
9+
behavior.
10+
11+
## Basic scrolling
12+
13+
Many Flutter widgets support scrolling out of the box
14+
and do most of the work for you. For example,
15+
[`SingleChildScrollView`][] automatically scrolls its
16+
child when necessary. Other useful widgets include
17+
[`ListView`][] and [`GridView`][].
18+
You can check out more of these widgets on the
19+
[scrolling page][] of the Widget catalog.
20+
21+
<iframe width="560" height="315" src="https://www.youtube.com/embed/DbkIQSvwnZc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
22+
23+
<iframe width="560" height="315" src="https://www.youtube.com/embed/KJpkjHGiI5A" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
24+
25+
## Infinite scrolling
26+
27+
When you have a long list of items
28+
in your `ListView` or `GridView` (including an _infinite_ list),
29+
you can build the items on demand
30+
as they scroll into view. This provides a much
31+
more performant scrolling experience.
32+
For more information, check out
33+
[`ListView.builder`][] or [`GridView.builder`][].
34+
35+
[`ListView.builder`]: {{site.api}}/flutter/widgets/ListView/ListView.builder.html
36+
[`GridView.builder`]: {{site.api}}/flutter/widgets/GridView/GridView.builder.html
37+
38+
### Specialized scrollable widgets
39+
40+
The following widgets provide more specific scrolling
41+
behavior.
42+
43+
A video on using [`DraggableScrollableSheet`][]
44+
<iframe width="560" height="315" src="https://www.youtube.com/embed/Hgw819mL_78" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
45+
46+
Turn the scrollable area into a wheel! [`ListWheelScrollView`][]
47+
<iframe width="560" height="315" src="https://www.youtube.com/embed/dUhmWAz4C7Y" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
48+
49+
[`DraggableScrollableSheet`]: {{site.api}}/flutter/widgets/DraggableScrollableSheet-class.html
50+
[`GridView`]: {{site.api}}/flutter/widgets/GridView-class.html
51+
[`ListView`]: {{site.api}}/flutter/widgets/ListView-class.html
52+
[`ListWheelScrollView`]: {{site.api}}/flutter/widgets/ListWheelScrollView-class.html
53+
[scrolling page]: {{site.url}}/ui/widgets/scrolling
54+
[`SingleChildScrollView`]: {{site.api}}/flutter/widgets/SingleChildScrollView-class.html
55+
56+
{% comment %}
57+
Not yet, but coming. Two dimensional scrolling:
58+
TableView and TreeView.
59+
Video: https://www.youtube.com/watch?v=UDZ0LPQq-n8
60+
{% endcomment %}
61+
62+
## Fancy scrolling
63+
64+
Perhaps you want to implement _elastic_ scrolling,
65+
also called _scroll bouncing_. Or maybe you want to
66+
implement other dynamic scrolling effects, like parallax scrolling.
67+
Or perhaps you want a scrolling header with very specific behavior,
68+
such as shrinking or disappearing.
69+
70+
You can achieve all this and more using the
71+
Flutter `Sliver*` classes.
72+
A _sliver_ refers to a piece of the scrollable area.
73+
You can define and insert a sliver into a [`CustomScrollView`][]
74+
to have finer-grained control over that area.
75+
76+
For more information, check out
77+
[Using slivers to achieve fancy scrolling][]
78+
and the [Sliver classes][].
79+
80+
[`CustomScrollView`]: {{site.api}}/flutter/widgets/CustomScrollView-class.html
81+
[Sliver classes]: {{site.url}}/ui/widgets/layout#Sliver%20widgets
82+
[Using slivers to achieve fancy scrolling]: {{site.url}}/ui/scrolling/slivers
83+
84+
## Nested scrolling widgets
85+
86+
How do you nest a scrolling widget
87+
inside another scrolling widget
88+
without hurting scrolling performance?
89+
Do you set the `ShrinkWrap` property to true,
90+
or do you use a sliver?
91+
92+
Check out the "ShrinkWrap vs Slivers" video:
93+
94+
<iframe width="560" height="315" src="https://www.youtube.com/embed/LUqDNnv_dh0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

src/ui/advanced/slivers.md renamed to src/ui/scrolling/slivers.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ can define to behave in a special way.
99
You can use slivers to achieve custom scrolling effects,
1010
such as elastic scrolling.
1111

12-
For a free, instructor-led video workshop that also uses DartPad,
12+
For a free, instructor-led video workshop that uses DartPad,
1313
check out the following video about using slivers:
1414

1515
<iframe width="560" height="315" src="{{site.youtube-site}}/embed/YY-_yrZdjGc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
@@ -27,7 +27,7 @@ in Flutter, see the following resources:
2727
using the sliver classes.
2828
</dd>
2929

30-
<dt markdown="1"> **[SliverAppBar][]**
30+
<dt markdown="1"> **[SliverAppBar][sliver-app-bar-video]**
3131
</dt>
3232
<dd markdown="1">A one-minute Widget-of-the-week
3333
video that gives an overview of the
@@ -59,12 +59,14 @@ in Flutter, see the following resources:
5959

6060
Here some links to relevant API docs:
6161

62+
* [`CustomScrollView`][]
6263
* [`SliverAppBar`][]
6364
* [`SliverGrid`][]
6465
* [`SliverList`][]
6566

6667

67-
[SliverAppBar]: {{site.youtube-site}}/watch?v=R9C5KMJKluE
68+
[`CustomScrollView`]: {{site.api}}/flutter/widgets/CustomScrollView-class.html`
69+
[sliver-app-bar-video]: {{site.youtube-site}}/watch?v=R9C5KMJKluE
6870
[`SliverAppBar`]: {{site.api}}/flutter/material/SliverAppBar-class.html
6971
[`SliverGrid`]: {{site.api}}/flutter/widgets/SliverGrid-class.html
7072
[SliverList and SliverGrid]: {{site.youtube-site}}/watch?v=ORiTTaVY6mM

0 commit comments

Comments
 (0)