-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.dart
116 lines (107 loc) · 3.7 KB
/
main.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Example using ScrollableView, though it provides context to ScrollHaptics and KeyboardDismiss as well.
import 'package:flutter/material.dart';
import 'package:scrollable/exports.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: "Demo",
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const HomeScreen(),
);
}
}
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
final ScrollController controller = ScrollController();
@override
void dispose() {
controller.dispose(); // <----- Remember to dispose the controller
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Includes haptics (hard to show)"),
),
body: ScrollableView(
// MORE PROPERTIES GO HERE
controller: controller,
child: SingleChildScrollView(
physics: const ClampingScrollPhysics(),
// ... HAS MANY MORE PROPERTIES ...
controller: controller,
child: Column(
children: [
Container(
width: double.infinity,
color: Colors.blue,
child: const Align(
alignment: Alignment.topCenter,
child: Text(
"^ Inline padding. This allows the ScrollableView to have an 'in-scroll' offset, instead of having to wrap the outside of the scroll view with padding, or filling it with SizedBoxes. At bottom too.",
style: TextStyle(color: Colors.white, fontSize: 25),
textAlign: TextAlign.center,
),
),
),
Container(width: double.infinity, height: 150, color: Colors.red),
Container(
width: double.infinity, height: 150, color: Colors.green),
Container(
width: double.infinity, height: 150, color: Colors.pink),
Container(
width: double.infinity,
color: Colors.white,
child: Column(
children: [
const Text(
"Example textfield to open keyboard, and show it closes on scroll (or tap).",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 35),
),
TextFormField(
decoration: const InputDecoration(
hintText: "Example textfield.",
),
),
],
),
),
Container(
width: double.infinity, height: 150, color: Colors.purple),
Container(
width: double.infinity, height: 150, color: Colors.cyan),
Container(
width: double.infinity, height: 150, color: Colors.brown),
Container(
width: double.infinity,
height: 150,
color: Colors.orangeAccent),
Container(
width: double.infinity,
height: 150,
color: Colors.lightGreen),
Container(
width: double.infinity,
height: 150,
color: Colors.yellowAccent),
],
),
),
),
);
}
}