Slide 1

Slide 1 text

ON THE INSIDE BIGGER FLUTTER SCROLLING EXPLAINED Sebastiano Poggi Eugenio Marletti

Slide 2

Slide 2 text

A little disclaimer

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

ScrollController ScrollPosition ScrollContext ScrollDirection ScrollBehavior ScrollConfiguration ScrollNotification ScrollStartNotification ScrollUpdateNotification OverscrollNotification UserScrollNotification ScrollEndNotification Scrollbar RefreshIndicator GlowingOverscrollIndicator SliverAppBar RenderBox Viewport ShrinkWrappingViewport RenderAbstractViewport RenderViewportBase RenderViewport RenderShrinkWrappingViewport ScrollActivity IdleScrollActivity HoldScrollActivity DragScrollActivity BallisticScrollActivity DrivenScrollActivity ScrollHoldController ScrollDragController NestedScrollView SingleChildScrollView PageView ScrollView BoxScrollView ListView GridView CustomScrollView SliverPadding SliverFillRemaining SliverPersistentHeader SliverToBoxAdapter SliverMultiBoxAdaptorWidget SliverList SliverFixedExtentList SliverGrid SliverFillViewport SliverPrototypeExtentList RenderSliver RenderSliverPadding RenderSliverSingleBoxAdapter RenderSliverToBoxAdapter RenderSliverFillRemaining RenderSliverMultiBoxAdaptor RenderSliverList RenderSliverGrid RenderSliverFixedExtentBoxAdaptor RenderSliverFixedExtentList RenderSliverFillViewport _RenderSliverPrototypeExtentList RenderSliverPersistentHeader RenderSliverScrollingPersistentHeader RenderSliverPinnedPersistentHeader RenderSliverFloatingPersistentHeader RenderSliverFloatingPinnedPersistentHeader Scrollable RenderObject BoxConstraints Size SliverConstraints SliverGeometry ViewportOffset ScrollMetrics ScrollPhysics BouncingScrollPhysics ClampingScrollPhysics AlwaysScrollableScrollPhysics NeverScrollableScrollPhysics Simulation BouncingScrollSimulation ClampingScrollSimulation AlwaysScrollableScrollPhysics NeverScrollableScrollPhysics

Slide 5

Slide 5 text

THE END

Slide 6

Slide 6 text

37 MINUTES EARLIER...

Slide 7

Slide 7 text

SCROLLING

Slide 8

Slide 8 text

SCROLLING KEY FACTS: it’s everywhere it’s hard it’s very hard why?

Slide 9

Slide 9 text

SCROLLING Physical metaphor Effects Interaction patterns Multimodal navigation Accessibility expectations bounce, glow, … scrollbars, pull-to-refresh, … touch, D-pad, keyboard & mouse, …

Slide 10

Slide 10 text

SCROLLING PERFORMANCE IS HARD

Slide 11

Slide 11 text

SCROLLING PERFORMANCE IS HARD ABSTRACTIONS ARE HARD

Slide 12

Slide 12 text

SCROLLING PERFORMANCE IS HARD GOOD ABSTRACTIONS ARE HARD

Slide 13

Slide 13 text

SCROLLING PERFORMANCE IS HARD GOOD ABSTRACTIONS ARE HARD ListView RecyclerView

Slide 14

Slide 14 text

SCROLLING PERFORMANCE IS HARD GOOD ABSTRACTIONS ARE HARD ListView RecyclerView easy to use, classic use-cases, not customisable low-level, many things are customisable, harder to use

Slide 15

Slide 15 text

WHAT ABOUT FLUTTER?

Slide 16

Slide 16 text

DETOUR

Slide 17

Slide 17 text

HOW UI WORKS IN FLUTTER RENDER OBJECT time SCREEN PIXELS ELEMENT WIDGET WIDGET WIDGET Widgets map to Elements Elements update RenderObjects You deal with Widgets RenderObjects draw on screen build() build() build()

Slide 18

Slide 18 text

END OF DETOUR

Slide 19

Slide 19 text

SCROLLING IN FLUTTER Used to be different The Great Scrolling Refactor (2016)

Slide 20

Slide 20 text

SCROLLING IN FLUTTER Scrolling is just a “normal” layout Solid abstractions Self-contained No special machinery

Slide 21

Slide 21 text

SCROLLING IN FLUTTER Scrolling is still very complicated BUT you don’t need to see it Unless you’re a crazy elf

Slide 22

Slide 22 text

SCROLLING WIDGETS ListView RefreshIndicator PageView CustomScrollView

Slide 23

Slide 23 text

ListView

Slide 24

Slide 24 text

RefreshIndicator

Slide 25

Slide 25 text

PageView

Slide 26

Slide 26 text

CustomScrollView

Slide 27

Slide 27 text

ANATOMY OF A SCROLL

Slide 28

Slide 28 text

SCROLLABLE COMPONENT ANATOMY OF A SCROLL

Slide 29

Slide 29 text

SCROLLABLE COMPONENT INTERACTION CONTAINER CONTENTS ANATOMY OF A SCROLL

Slide 30

Slide 30 text

CONTENTS SLIVERS ANATOMY OF A SCROLL SCROLLABLE COMPONENT CONTAINER VIEWPORT SCROLLING INTERACTION

Slide 31

Slide 31 text

CONTAINER the easy bit™

Slide 32

Slide 32 text

CONTAINER Introducing Viewport It’s bigger on the inside

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Display children at a specific offset Children are Slivers Viewport

Slide 35

Slide 35 text

Picks centre Sliver Centre Sliver is the anchor Viewport center

Slide 36

Slide 36 text

Viewport Picks centre Sliver Centre Sliver is the anchor center

Slide 37

Slide 37 text

center Viewport Picks centre Sliver Centre Sliver is the anchor

Slide 38

Slide 38 text

Viewport defines a scrolling axis Centre Sliver has absolute position Between [0, 1] Viewport center 0 1

Slide 39

Slide 39 text

Default configuration center center = children.first axisDirection = AxisDirection.down anchor = 0.0 Viewport 0

Slide 40

Slide 40 text

Viewports Viewport ShrinkWrappingViewport

Slide 41

Slide 41 text

INTERACTION the user-facing bit™

Slide 42

Slide 42 text

INTERACTION Widget: Scrollable It scrolls. Duh. ¯\_(ϑ)_/¯

Slide 43

Slide 43 text

INTERACTION Widget: Scrollable It scrolls. Duh. Handles gestures

Slide 44

Slide 44 text

INTERACTION ViewportBuilder Physics Controller SCROLLABLE

Slide 45

Slide 45 text

ScrollView SingleChildScrollView PageView INTERACTION SCROLLABLE

Slide 46

Slide 46 text

CONTENTS the esoteric bit™

Slide 47

Slide 47 text

DETOUR

Slide 48

Slide 48 text

RENDERBOX RenderObject for 2D Carthesian coordinates Basically a box with a size Internal coordinate system

Slide 49

Slide 49 text

max max

Slide 50

Slide 50 text

max max

Slide 51

Slide 51 text

max max

Slide 52

Slide 52 text

max max min min

Slide 53

Slide 53 text

min min max max

Slide 54

Slide 54 text

max min min max

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

0,0 x,y

Slide 57

Slide 57 text

0,0 x,y

Slide 58

Slide 58 text

END OF DETOUR

Slide 59

Slide 59 text

CONTENTS Viewports display slivers Slivers are “slices” of content RenderSliver is the main class Sliver widgets wrap RenderSlivers

Slide 60

Slide 60 text

H G F E D C B A S T U V W X Y Z axisDirection down

Slide 61

Slide 61 text

growth direction forward H G F E D C B A S T U V W X Y Z axisDirection down growth direction reverse

Slide 62

Slide 62 text

growth direction forward user scroll direction H G F E D C B A S T U V W X Y Z axisDirection down user scroll direction growth direction reverse

Slide 63

Slide 63 text

growth direction forward user scroll direction idle H G F E D C B A S T U V W X Y Z axisDirection down user scroll direction idle growth direction reverse

Slide 64

Slide 64 text

growth direction forward user scroll direction forward H G F E D C B A S T U V W X Y Z axisDirection down user scroll direction reverse growth direction reverse

Slide 65

Slide 65 text

growth direction forward user scroll direction forward J I H G F E D C B Q R S T U V W X Y axisDirection down user scroll direction reverse growth direction reverse

Slide 66

Slide 66 text

growth direction forward user scroll direction reverse J I H G F E D C B Q R S T U V W X Y axisDirection down user scroll direction forward growth direction reverse

Slide 67

Slide 67 text

growth direction forward user scroll direction reverse H G F E D C B A S T U V W X Y Z axisDirection down user scroll direction forward growth direction reverse

Slide 68

Slide 68 text

growth direction forward user scroll direction idle H G F E D C B A S T U V W X Y Z axisDirection down user scroll direction idle growth direction reverse

Slide 69

Slide 69 text

G F E D C B A

Slide 70

Slide 70 text

E D C B A crossAxisExtent

Slide 71

Slide 71 text

E D C B A viewportMainAxisExtent crossAxisExtent

Slide 72

Slide 72 text

E D C B A remainingPaintExtent

Slide 73

Slide 73 text

E D C B A remainingPaintExtent

Slide 74

Slide 74 text

E D C B A remainingPaintExtent

Slide 75

Slide 75 text

E D C B A remainingPaintExtent

Slide 76

Slide 76 text

E D C B A remainingPaintExtent

Slide 77

Slide 77 text

E D C B A

Slide 78

Slide 78 text

E D C B A overlap

Slide 79

Slide 79 text

I H G F E D C B A scrollOffset 150.0 50.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

Slide 80

Slide 80 text

SLIVER GEOMETRY Scroll extent Paint extent (and origin) Layout extent

Slide 81

Slide 81 text

TYING IT ALL TOGETHER

Slide 82

Slide 82 text

ScrollController ScrollPosition ScrollContext ScrollDirection ScrollBehavior ScrollConfiguration ScrollNotification ScrollStartNotification ScrollUpdateNotification OverscrollNotification UserScrollNotification ScrollEndNotification Scrollbar RefreshIndicator GlowingOverscrollIndicator SliverAppBar RenderBox Viewport ShrinkWrappingViewport RenderAbstractViewport RenderViewportBase RenderViewport RenderShrinkWrappingViewport ScrollActivity IdleScrollActivity HoldScrollActivity DragScrollActivity BallisticScrollActivity DrivenScrollActivity ScrollHoldController ScrollDragController NestedScrollView SingleChildScrollView PageView ScrollView BoxScrollView ListView GridView CustomScrollView SliverPadding SliverFillRemaining SliverPersistentHeader SliverToBoxAdapter SliverMultiBoxAdaptorWidget SliverList SliverFixedExtentList SliverGrid SliverFillViewport SliverPrototypeExtentList RenderSliver RenderSliverPadding RenderSliverSingleBoxAdapter RenderSliverToBoxAdapter RenderSliverFillRemaining RenderSliverMultiBoxAdaptor RenderSliverList RenderSliverGrid RenderSliverFixedExtentBoxAdaptor RenderSliverFixedExtentList RenderSliverFillViewport _RenderSliverPrototypeExtentList RenderSliverPersistentHeader RenderSliverScrollingPersistentHeader RenderSliverPinnedPersistentHeader RenderSliverFloatingPersistentHeader RenderSliverFloatingPinnedPersistentHeader Scrollable RenderObject BoxConstraints Size SliverConstraints SliverGeometry ViewportOffset ScrollMetrics ScrollPhysics BouncingScrollPhysics ClampingScrollPhysics AlwaysScrollableScrollPhysics NeverScrollableScrollPhysics Simulation BouncingScrollSimulation ClampingScrollSimulation AlwaysScrollableScrollPhysics NeverScrollableScrollPhysics

Slide 83

Slide 83 text

THE END

Slide 84

Slide 84 text

ON THE INSIDE BIGGER FLUTTER SCROLLING EXPLAINED bit.ly/flutter-scrolling Sebastiano Poggi Eugenio Marletti Novoda Clue @seebrock3r @workingkills