buildContent method
Builds the content of the indicator.
Implementation
@override
Widget buildContent(BuildContext context, RefreshStatus? mode) {
final double indicatorOpacity = mode == RefreshStatus.idle
? 0.0
: const Interval(0.0, 0.2, curve: Curves.easeIn).transform(_progress);
final bool isCompleting =
mode == RefreshStatus.completed || mode == RefreshStatus.failed;
final double dismissValue =
Curves.easeOut.transform(_dismissController.value);
final double dismissScale =
isCompleting ? ui.lerpDouble(1.0, 0.5, dismissValue) ?? 0.5 : 1.0;
final double dismissOpacity = isCompleting ? 1.0 - dismissValue : 1.0;
final bool showTimestamp = widget.showLastUpdated &&
mode == RefreshStatus.completed &&
_lastUpdatedAt != null;
final RefreshString strings =
RefreshLocalizations.of(context)?.currentLocalization ??
EnRefreshString();
final String label = widget.semanticsLabel ??
(mode == RefreshStatus.completed
? strings.refreshCompleteText!
: mode == RefreshStatus.failed
? strings.refreshFailedText!
: mode == RefreshStatus.refreshing
? strings.refreshingText!
: mode == RefreshStatus.canRefresh
? strings.canRefreshText!
: strings.idleRefreshText!);
final Widget indicator = AnimatedBuilder(
animation: Listenable.merge(<Listenable>[
_rotationController,
_scaleController,
_opacityController,
_dismissController,
]),
builder: (BuildContext context, Widget? child) {
return Opacity(
opacity: (indicatorOpacity * dismissOpacity).clamp(0.0, 1.0),
child: Transform.scale(
scale: _scaleAnimation.value * dismissScale,
child: Ios17ActivityIndicator(
color: _resolvedColor,
radius: widget.radius,
progress: mode == RefreshStatus.refreshing || isCompleting
? 1.0
: _progress,
rotationValue: _rotationController.value,
gradientOpacity: mode == RefreshStatus.refreshing ||
mode == RefreshStatus.completed ||
mode == RefreshStatus.failed
? Curves.easeIn.transform(_opacityController.value)
: 0.0,
),
),
);
},
);
Widget content = indicator;
if (showTimestamp) {
final String text = widget.lastUpdatedTextBuilder != null
? debugIos17HeaderLastUpdatedText(
updatedAt: _lastUpdatedAt!,
builder: widget.lastUpdatedTextBuilder,
)
: debugIos17HeaderLastUpdatedText(
updatedAt: _lastUpdatedAt!,
now: DateTime.now(),
);
content = Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
indicator,
const SizedBox(height: 4.0),
Opacity(
opacity: dismissOpacity.clamp(0.0, 1.0),
child: Text(
text,
style: CupertinoTheme.of(context)
.textTheme
.tabLabelTextStyle
.copyWith(color: _resolvedColor, fontSize: 11.0),
),
),
],
);
}
return SizedBox(
height: widget.height,
child: Center(
child: Semantics(
label: label,
hint: widget.semanticsHint,
child: content,
),
),
);
}