Skip to content

Commit 4e902f1

Browse files
new release
1 parent 7e2bc32 commit 4e902f1

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
## 0.0.1
22

33
* Initial Release
4+
5+
## 0.0.2
6+
7+
* Added Examples

example/example.dart

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:scroll_to_top/scroll_to_top.dart';
3+
4+
void main() {
5+
runApp(const MyApp());
6+
}
7+
8+
class MyApp extends StatelessWidget {
9+
const MyApp({Key? key}) : super(key: key);
10+
11+
@override
12+
Widget build(BuildContext context) {
13+
return MaterialApp(
14+
title: 'Scroll To Top',
15+
theme: ThemeData(
16+
primarySwatch: Colors.blue,
17+
),
18+
home: const MyHomePage(),
19+
);
20+
}
21+
}
22+
23+
class MyHomePage extends StatefulWidget {
24+
const MyHomePage({Key? key}) : super(key: key);
25+
26+
@override
27+
State<MyHomePage> createState() => _MyHomePageState();
28+
}
29+
30+
class _MyHomePageState extends State<MyHomePage> {
31+
final ScrollController _scrollController = ScrollController();
32+
@override
33+
Widget build(BuildContext context) {
34+
return Scaffold(
35+
appBar: AppBar(title: const Text("Scroll to top")),
36+
body: ScrollToTop(
37+
scrollController: _scrollController,
38+
child: buildListView(_scrollController),
39+
),
40+
);
41+
}
42+
43+
Widget buildListView(ScrollController scrollController) => ListView.builder(
44+
controller: scrollController,
45+
physics: const BouncingScrollPhysics(),
46+
itemCount: 50,
47+
itemBuilder: (context, index) {
48+
return SizedBox(
49+
width: 20,
50+
child: Padding(
51+
padding: const EdgeInsets.all(8.0),
52+
child: Container(
53+
width: 20,
54+
decoration: BoxDecoration(
55+
borderRadius: BorderRadius.circular(10.5),
56+
color: Colors.green[100],
57+
),
58+
child: Center(
59+
child: Align(
60+
alignment: Alignment.centerLeft,
61+
child: Padding(
62+
padding: const EdgeInsets.all(8.0),
63+
child: Text("Index $index"),
64+
),
65+
),
66+
),
67+
),
68+
),
69+
);
70+
},
71+
);
72+
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: scroll_to_top
22
description: This package will help us reach the top of the page based on scroll offsets.
3-
version: 0.0.1
3+
version: 0.0.2
44
homepage: https://github.com/vijayinyoutube/scroll_to_top
55

66
environment:

0 commit comments

Comments
 (0)