load method
Implementation
Future load() async {
var response = await _repository.getChatMessages(
session.email ?? '', session.businessId ?? '', session.id ?? '');
if (response.isSuccessful && response.body != null) {
var body = response.body!;
value = value.copyWith(isLoading: false, messages: body);
Future.delayed(const Duration(milliseconds: 500), () {
if (scrollController.hasClients) {
scrollController.animateTo(scrollController.position.maxScrollExtent,
duration: const Duration(milliseconds: 300),
curve: Curves.decelerate);
}
});
} else {
value = value.copyWith(isLoading: false);
}
}