Skip to content

Commit 5dbb122

Browse files
committed
docs: deprecate the withRotation parameter of CustomMaterialIndicator widget
1 parent 3ca6e2a commit 5dbb122

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## 3.1.2
2+
- Deprecated the *withRotation* argument of the *CustomMaterialIndicator* widget. The rotation function will be removed in the upcoming version.
13
## 3.1.1
24
- Fix:
35
- Fixed *durations* parameter of *CustomRefreshIndicator* widget. Reported by [@jccd1996](https://github.com/jccd1996) in [#58](https://github.com/gonuit/flutter-custom-refresh-indicator/issues/58).

lib/src/widgets/custom_material_indicator.dart

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ class CustomMaterialIndicator extends StatelessWidget {
6363

6464
/// When set to *true*, the indicator will rotate
6565
/// in the [IndicatorState.loading] state.
66+
@Deprecated(
67+
'This is not part of the material indicator and will be removed in the next version. '
68+
'To keep the rotation logic, please implement the rotation on your own and do not rely on this property.',
69+
)
6670
final bool withRotation;
6771

6872
/// {@macro custom_refresh_indicator.notification_predicate}
@@ -102,10 +106,15 @@ class CustomMaterialIndicator extends StatelessWidget {
102106
required this.onRefresh,
103107
required this.indicatorBuilder,
104108
this.scrollableBuilder = _defaultBuilder,
105-
this.notificationPredicate = CustomRefreshIndicator.defaultScrollNotificationPredicate,
109+
this.notificationPredicate =
110+
CustomRefreshIndicator.defaultScrollNotificationPredicate,
106111
this.backgroundColor,
107112
this.displacement = 40.0,
108113
this.edgeOffset = 0.0,
114+
@Deprecated(
115+
'This is not part of the material indicator and will be removed in the next version. '
116+
'To keep the rotation logic, please implement the rotation on your own and do not rely on this property.',
117+
)
109118
this.withRotation = true,
110119
this.elevation = 2.0,
111120
this.clipBehavior = Clip.none,
@@ -119,7 +128,9 @@ class CustomMaterialIndicator extends StatelessWidget {
119128
this.trailingScrollIndicatorVisible = true,
120129
});
121130

122-
static Widget _defaultBuilder(BuildContext context, Widget child, IndicatorController controller) => child;
131+
static Widget _defaultBuilder(
132+
BuildContext context, Widget child, IndicatorController controller) =>
133+
child;
123134

124135
@override
125136
Widget build(BuildContext context) {
@@ -147,7 +158,9 @@ class CustomMaterialIndicator extends StatelessWidget {
147158
displacement: displacement,
148159
controller: controller,
149160
child: ScaleTransition(
150-
scale: controller.isFinalizing ? controller.clamp(0.0, 1.0) : const AlwaysStoppedAnimation(1.0),
161+
scale: controller.isFinalizing
162+
? controller.clamp(0.0, 1.0)
163+
: const AlwaysStoppedAnimation(1.0),
151164
child: Container(
152165
width: 41,
153166
height: 41,
@@ -162,7 +175,8 @@ class CustomMaterialIndicator extends StatelessWidget {
162175
child: autoRebuild
163176
? AnimatedBuilder(
164177
animation: controller,
165-
builder: (context, _) => indicatorBuilder(context, controller),
178+
builder: (context, _) =>
179+
indicatorBuilder(context, controller),
166180
)
167181
: indicatorBuilder(context, controller),
168182
),
@@ -235,11 +249,14 @@ class _PositionedIndicatorContainer extends StatelessWidget {
235249
? AlignmentDirectional(-1.0, side.isTop ? 1.0 : -1.0)
236250
: AlignmentDirectional(side.isLeft ? 1.0 : -1.0, -1.0);
237251

238-
final endOffset = isVerticalAxis ? Offset(0.0, side.isTop ? 1.0 : -1.0) : Offset(side.isLeft ? 1.0 : -1.0, 0.0);
252+
final endOffset = isVerticalAxis
253+
? Offset(0.0, side.isTop ? 1.0 : -1.0)
254+
: Offset(side.isLeft ? 1.0 : -1.0, 0.0);
239255

240256
final animation = controller.isFinalizing
241257
? AlwaysStoppedAnimation(endOffset)
242-
: Tween(begin: const Offset(0.0, 0.0), end: endOffset).animate(controller);
258+
: Tween(begin: const Offset(0.0, 0.0), end: endOffset)
259+
.animate(controller);
243260

244261
return Positioned(
245262
top: isHorizontalAxis
@@ -294,7 +311,8 @@ class _InfiniteRotation extends StatefulWidget {
294311
_InfiniteRotationState createState() => _InfiniteRotationState();
295312
}
296313

297-
class _InfiniteRotationState extends State<_InfiniteRotation> with SingleTickerProviderStateMixin {
314+
class _InfiniteRotationState extends State<_InfiniteRotation>
315+
with SingleTickerProviderStateMixin {
298316
late AnimationController _rotationController;
299317

300318
@override
@@ -337,5 +355,6 @@ class _InfiniteRotationState extends State<_InfiniteRotation> with SingleTickerP
337355
}
338356

339357
@override
340-
Widget build(BuildContext context) => RotationTransition(turns: _rotationController, child: widget.child);
358+
Widget build(BuildContext context) =>
359+
RotationTransition(turns: _rotationController, child: widget.child);
341360
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: custom_refresh_indicator
22
description: Widget that makes it easy to implement a custom pull to refresh gesture.
3-
version: 3.1.1
3+
version: 3.1.2
44
repository: https://github.com/gonuit/flutter-custom-refresh-indicator
55
issue_tracker: https://github.com/gonuit/flutter-custom-refresh-indicator/issues
66
homepage: https://github.com/gonuit/flutter-custom-refresh-indicator

0 commit comments

Comments
 (0)