loadCollection method
Implementation
Future<void> loadCollection(String collection, {bool showLoading = true}) async {
if (selectedSourceId == null) return;
_ensureTablePagination(collection);
final collectionChanged = columnsTable != collection;
if (showLoading && (pagination!.isInitialLoad || collectionChanged)) {
loading = true;
notifyListeners();
}
try {
if (collectionChanged || columns.isEmpty) {
columns = await _getColumns(selectedSourceId!, collection);
columnsTable = collection;
notifyListeners();
}
await pagination!.loadPage(0);
_resetQueryState();
_resetSearchAndSort();
loading = false;
notifyListeners();
} catch (error) {
loading = false;
lastError = 'Failed to load rows: $error';
notifyListeners();
}
}