Skip to content

Commit eed5989

Browse files
authored
Create refresh_indicator.dart
1 parent 268d63c commit eed5989

File tree

1 file changed

+142
-0
lines changed

1 file changed

+142
-0
lines changed

refresh_indicator.dart

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
//Flutter Custom Refresh Indicator
2+
// This package provides CustomRefreshIndicator widget that make it easy to implement your own custom refresh indicator.
3+
//It listens for scroll events from scroll widget passed to child argument and parsing it to data easy for custom refresh indicator implementation.
4+
//Indicator data is provided by IndicatorController (third argument of builder method). Long story short... thats it!
5+
6+
7+
import 'package:example/screens/presentation_screen.dart';
8+
import 'package:flutter/material.dart';
9+
10+
import 'indicators/simple_indicator.dart';
11+
import 'screens/example_indicator_screen.dart';
12+
import 'screens/ice_cream_indicator_screen.dart';
13+
import 'screens/plane_indicator_screen.dart';
14+
import 'screens/check_mark_indicator_screen.dart';
15+
import 'screens/warp_indicator_screen.dart';
16+
17+
void main() => runApp(MyApp());
18+
19+
class MyApp extends StatelessWidget {
20+
@override
21+
Widget build(BuildContext context) {
22+
return MaterialApp(
23+
title: 'CustomRefreshIndicator demo',
24+
theme: ThemeData(
25+
primarySwatch: Colors.blue,
26+
),
27+
home: MainScreen(),
28+
routes: {
29+
'/example': (context) => ExampleIndicatorScreen(),
30+
'/plane': (context) => PlaneIndicatorScreen(),
31+
'/ice_cream': (context) => IceCreamIndicatorScreen(),
32+
'/presentation': (context) => PresentationScreen(),
33+
'/check-mark': (context) => CheckMarkIndicatorScreen(),
34+
'/warp': (context) => WarpIndicatorScreen(),
35+
},
36+
);
37+
}
38+
}
39+
40+
class MainScreen extends StatelessWidget {
41+
@override
42+
Widget build(BuildContext context) {
43+
return Scaffold(
44+
appBar: AppBar(
45+
title: Text("Examples"),
46+
),
47+
body: SafeArea(
48+
child: ListView(
49+
padding: const EdgeInsets.all(15),
50+
children: <Widget>[
51+
ElevatedButton(
52+
child: Container(
53+
height: 50,
54+
alignment: Alignment.center,
55+
child: Text("Presentation"),
56+
),
57+
onPressed: () => Navigator.pushNamed(
58+
context,
59+
'/presentation',
60+
),
61+
),
62+
const SizedBox(height: 15),
63+
ElevatedButton(
64+
child: Container(
65+
height: 50,
66+
alignment: Alignment.center,
67+
child: Text("Simple"),
68+
),
69+
onPressed: () => Navigator.pushNamed(
70+
context,
71+
'/example',
72+
arguments: simpleIndicator,
73+
),
74+
),
75+
const SizedBox(height: 15),
76+
ElevatedButton(
77+
child: Container(
78+
height: 50,
79+
alignment: Alignment.center,
80+
child: Text("Simple with list opacity"),
81+
),
82+
onPressed: () => Navigator.pushNamed(
83+
context,
84+
'/example',
85+
arguments: simpleIndicatorWithOpacity,
86+
),
87+
),
88+
const SizedBox(height: 15),
89+
ElevatedButton(
90+
child: Container(
91+
height: 50,
92+
alignment: Alignment.center,
93+
child: Text("Plane"),
94+
),
95+
onPressed: () => Navigator.pushNamed(
96+
context,
97+
'/plane',
98+
),
99+
),
100+
const SizedBox(height: 15),
101+
ElevatedButton(
102+
child: Container(
103+
height: 50,
104+
alignment: Alignment.center,
105+
child: Text("Ice cream"),
106+
),
107+
onPressed: () => Navigator.pushNamed(
108+
context,
109+
'/ice_cream',
110+
),
111+
),
112+
const SizedBox(height: 15),
113+
ElevatedButton(
114+
child: Container(
115+
height: 50,
116+
alignment: Alignment.center,
117+
child: Text("Check mark"),
118+
),
119+
onPressed: () => Navigator.pushNamed(
120+
context,
121+
'/check-mark',
122+
),
123+
),
124+
const SizedBox(height: 15),
125+
ElevatedButton(
126+
child: Container(
127+
height: 50,
128+
alignment: Alignment.center,
129+
child: Text("Warp indicator"),
130+
),
131+
onPressed: () => Navigator.pushNamed(
132+
context,
133+
'/warp',
134+
arguments: simpleIndicator,
135+
),
136+
),
137+
],
138+
),
139+
),
140+
);
141+
}
142+
}

0 commit comments

Comments
 (0)