Skip to content

Commit 12d21b3

Browse files
committed
example app: update material indicator example
1 parent c6dc38d commit 12d21b3

File tree

2 files changed

+43
-25
lines changed

2 files changed

+43
-25
lines changed

example/lib/indicators/check_mark_indicator.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class _CheckMarkIndicatorState extends State<CheckMarkIndicator> with SingleTick
5050
@override
5151
Widget build(BuildContext context) {
5252
return CustomMaterialIndicator(
53-
withRotation: false,
5453
onRefresh: () => Future.delayed(const Duration(seconds: 2)),
5554
durations: const RefreshIndicatorDurations(
5655
completeDuration: Duration(seconds: 2),

example/lib/screens/custom_material_indicator_screen.dart

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,38 @@ class CustomMaterialIndicatorScreen extends StatefulWidget {
1313
class _CustomMaterialIndicatorScreenState extends State<CustomMaterialIndicatorScreen> {
1414
final _controller = IndicatorController();
1515

16+
bool _useCustom = true;
17+
18+
void _toggleCustom(bool useCustom) {
19+
// if no change exit
20+
if (_useCustom == useCustom) return;
21+
22+
setState(() {
23+
_useCustom = useCustom;
24+
});
25+
}
26+
1627
@override
1728
Widget build(BuildContext context) {
29+
final child = ExampleList(
30+
itemCount: 12,
31+
physics: AlwaysScrollableScrollPhysics(
32+
parent: _useCustom ? ClampingWithOverscrollPhysics(state: _controller) : const ClampingScrollPhysics(),
33+
),
34+
);
1835
return Scaffold(
1936
backgroundColor: appBackgroundColor,
20-
appBar: const ExampleAppBar(
37+
appBar: ExampleAppBar(
2138
elevation: 0,
39+
actions: [
40+
Text(
41+
_useCustom ? "CustomMaterialIndicator" : "RefreshIndicator",
42+
),
43+
Switch(
44+
value: _useCustom,
45+
onChanged: _toggleCustom,
46+
),
47+
],
2248
),
2349
body: SafeArea(
2450
child: Container(
@@ -28,29 +54,22 @@ class _CustomMaterialIndicatorScreenState extends State<CustomMaterialIndicatorS
2854
color: const Color(0xFFE2D8D7),
2955
),
3056
),
31-
child: CustomMaterialIndicator(
32-
controller: _controller,
33-
clipBehavior: Clip.antiAlias,
34-
trigger: IndicatorTrigger.bothEdges,
35-
triggerMode: IndicatorTriggerMode.anywhere,
36-
onRefresh: () => Future.delayed(const Duration(seconds: 2)),
37-
indicatorBuilder: (context, controller) {
38-
return const Icon(
39-
Icons.ac_unit,
40-
color: appContentColor,
41-
size: 30,
42-
);
43-
},
44-
scrollableBuilder: (context, child, controller) {
45-
return child;
46-
},
47-
child: ExampleList(
48-
itemCount: 12,
49-
physics: AlwaysScrollableScrollPhysics(
50-
parent: ClampingWithOverscrollPhysics(state: _controller),
51-
),
52-
),
53-
),
57+
child: _useCustom
58+
? CustomMaterialIndicator(
59+
clipBehavior: Clip.antiAlias,
60+
trigger: IndicatorTrigger.bothEdges,
61+
triggerMode: IndicatorTriggerMode.anywhere,
62+
onRefresh: () => Future.delayed(const Duration(seconds: 2)),
63+
scrollableBuilder: (context, child, controller) {
64+
return child;
65+
},
66+
child: child,
67+
)
68+
: RefreshIndicator(
69+
onRefresh: () => Future.delayed(const Duration(seconds: 2)),
70+
triggerMode: RefreshIndicatorTriggerMode.anywhere,
71+
child: child,
72+
),
5473
),
5574
),
5675
);

0 commit comments

Comments
 (0)