DiscoverModule/lib/contacts_module/provider_class/k2_provider/kol_viewnotes.dart

61 lines
1.4 KiB
Dart
Raw Normal View History

2024-11-22 10:38:43 +00:00
import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_fetchnotes_k2.dart';
import 'package:discover_module/contacts_module/service.dart/k2_service/Apicall_k2.dart';
import 'package:flutter/material.dart';
class HcpNotesFecth extends ChangeNotifier {
var call_api = CallK2api();
List<HcpNotes> listnotes = [];
List get ListNotes => listnotes;
bool _isLoading = false;
bool _hasMore = true;
int _page = 1;
final int _limit = 10;
bool get isLoading => _isLoading;
bool get hasMore => _hasMore;
// fetchhcpnotes() async {
// final listallnotes = await call_api.getallnotes();
// print("Hiiiiiilistallnotes : ${listallnotes}");
// listnotes = listallnotes!;
// notifyListeners();
// }
fetchhcpnotes() async {
if (_isLoading || !_hasMore) return;
_isLoading = true;
notifyListeners();
try {
// final events = await apicall.geteventsdatapagelimit(_page, _limit);
final listallnotes = await call_api.getallnotes(_page, _limit);
if (listallnotes!.isEmpty) {
_hasMore = false;
} else {
listnotes.addAll(listallnotes);
_page++;
// notifyListeners();
}
} catch (e) {
} finally {
_isLoading = false;
notifyListeners();
}
// final listallnotes = await call_api.getallnotes();
// print("Hiiiiiilistallnotes : ${listallnotes}");
// listnotes = listallnotes!;
// notifyListeners();
}
}