-
Notifications
You must be signed in to change notification settings - Fork 6
/
always_scrollable_scroll_physics_example.dart
50 lines (48 loc) · 1.9 KB
/
always_scrollable_scroll_physics_example.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import 'package:flutter/material.dart';
import 'package:flutter_tutorials/common/ui/widgets/bordered_container.dart';
class AlwaysScrollableScrollPhysicsExample extends StatelessWidget {
static const String routeName = 'always-scrollable-scroll-physics-example';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'AlwaysScrollableScrollPhysics Example',
style: Theme.of(context).textTheme.subtitle1!.copyWith(color: Colors.white, fontSize: 14),
),
),
body: SingleChildScrollView(
padding: const EdgeInsets.symmetric(vertical: 20),
physics: const AlwaysScrollableScrollPhysics(),
clipBehavior: Clip.none,
child: Column(
children: [
const Padding(
padding: EdgeInsets.symmetric(horizontal: 17),
child: Text(
'Adding AlwaysScrollableScrollPhysics to the parent SingleChildScrollView in this page forces scrolling even when the content of the scrollable widget’s content doesn’t exceed the height of the screen',
),
),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 17, vertical: 15),
child: Text(
'Note: It is important that you set shrinkWrap to true in the ListView.builder() widget or else you will get the scary "Vertical viewport was given unbounded height." Error',
),
),
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: 5,
itemBuilder: (c, i) => BorderedContainer(
child: Text(
'List Item ${i + 1}',
style: Theme.of(context).textTheme.headline6,
),
),
),
],
),
),
);
}
}