requestLoading method
Future<void>?
requestLoading(
{ - bool needMove = true,
- bool needCallback = true,
- Duration duration = const Duration(milliseconds: 300),
- Curve curve = Curves.linear,
})
Implementation
Future<void>? requestLoading(
{bool needMove = true,
bool needCallback = true,
Duration duration = const Duration(milliseconds: 300),
Curve curve = Curves.linear}) {
assert(position != null,
'Try not to call requestLoading() before build,please call after the ui was rendered');
if (isLoading) return Future.value();
StatefulElement? indicatorElement =
_findIndicator(position!.context.storageContext, LoadIndicator);
if (indicatorElement == null || _refresherState == null) return null;
(indicatorElement.state as LoadIndicatorState).floating = true;
if (needMove && _refresherState!.mounted)
_refresherState!.setCanDrag(false);
if (needMove) {
return Future.delayed(const Duration(milliseconds: 50)).then((_) async {
await position
?.animateTo(position!.maxScrollExtent,
duration: duration, curve: curve)
.then((_) {
if (_refresherState != null && _refresherState!.mounted) {
_refresherState!.setCanDrag(true);
if (needCallback) {
footerMode!.value = LoadStatus.loading;
} else {
footerMode!.setValueWithNoNotify(LoadStatus.loading);
if (indicatorElement.state.mounted) {
(indicatorElement.state as LoadIndicatorState).setState(() {});
}
}
}
});
});
} else {
return Future.value().then((_) {
footerMode!.value = LoadStatus.loading;
});
}
}