11import 'package:custom_refresh_indicator/custom_refresh_indicator.dart' ;
22import 'package:flutter/material.dart' ;
3- import 'dart:math' as math;
4-
5- typedef MaterialIndicatorBuilder = Widget Function (
6- BuildContext context,
7- IndicatorController controller,
8- );
93
104/// Builds a container that behaves similarly to the material refresh indicator
5+ @Deprecated ('In favor of CustomMaterialIndicator widget.' )
116class MaterialIndicatorDelegate extends IndicatorBuilderDelegate {
127 /// The distance from the child's top or bottom [edgeOffset] where
138 /// the refresh indicator will settle. During the drag that exposes the refresh
@@ -84,6 +79,7 @@ class MaterialIndicatorDelegate extends IndicatorBuilderDelegate {
8479 Theme .of (context).canvasColor;
8580
8681 return Stack (
82+ clipBehavior: Clip .hardEdge,
8783 children: < Widget > [
8884 scrollableBuilder (context, child, controller),
8985 _PositionedIndicatorContainer (
@@ -165,7 +161,7 @@ class _PositionedIndicatorContainer extends StatelessWidget {
165161
166162 @override
167163 Widget build (BuildContext context) {
168- if (controller.side.isNone) return const SizedBox ();
164+ if (controller.side.isNone) return const SizedBox . shrink ();
169165
170166 final isVerticalAxis = controller.side.isTop || controller.side.isBottom;
171167 final isHorizontalAxis = controller.side.isLeft || controller.side.isRight;
@@ -174,8 +170,6 @@ class _PositionedIndicatorContainer extends StatelessWidget {
174170 ? AlignmentDirectional (- 1.0 , controller.side.isTop ? 1.0 : - 1.0 )
175171 : AlignmentDirectional (controller.side.isLeft ? 1.0 : - 1.0 , - 1.0 );
176172
177- final double value = controller.isFinalizing ? 1.0 : controller.value;
178-
179173 return Positioned (
180174 top: isHorizontalAxis
181175 ? 0
@@ -197,15 +191,20 @@ class _PositionedIndicatorContainer extends StatelessWidget {
197191 : controller.side.isRight
198192 ? edgeOffset
199193 : null ,
200- child: ClipRRect (
201- child: Align (
202- alignment: alignment,
203- heightFactor: isVerticalAxis ? math.max (value, 0.0 ) : null ,
204- widthFactor: isHorizontalAxis ? math.max (value, 0.0 ) : null ,
205- child: Container (
194+ child: Align (
195+ alignment: alignment,
196+ heightFactor: isVerticalAxis ? 0.0 : null ,
197+ widthFactor: isHorizontalAxis ? 0.0 : null ,
198+ child: SlideTransition (
199+ position: controller.isFinalizing
200+ ? const AlwaysStoppedAnimation (Offset (0.0 , 1.0 ))
201+ : Tween (begin: const Offset (0.0 , 0.0 ), end: const Offset (0.0 , 1.0 )).animate (controller),
202+ child: Padding (
206203 padding: _getEdgeInsets (controller.side),
207- alignment: _getAlignement (controller.side),
208- child: child,
204+ child: Align (
205+ alignment: _getAlignement (controller.side),
206+ child: child,
207+ ),
209208 ),
210209 ),
211210 ),
0 commit comments