loadRows method

Future<List<CatalogRow>> loadRows({
  1. String? search,
  2. CatalogCellStatus? status,
})

Implementation

Future<List<CatalogRow>> loadRows({
  String? search,
  CatalogCellStatus? status,
}) async {
  final loaded = await _loadAndSyncState();
  final rows = loaded.rows.where((row) {
    if (search != null && search.trim().isNotEmpty) {
      final normalized = search.trim().toLowerCase();
      final keyMatch = row.keyPath.toLowerCase().contains(normalized);
      final valueMatch = row.valuesByLocale.values.any(
        (value) => (value?.toString().toLowerCase() ?? '').contains(normalized),
      );
      final noteMatch = (row.note?.toLowerCase() ?? '').contains(normalized);
      if (!keyMatch && !valueMatch && !noteMatch) {
        return false;
      }
    }

    if (status != null) {
      if (row.rowStatus != status) {
        return false;
      }
    }

    return true;
  }).toList();

  rows.sort((a, b) => a.keyPath.compareTo(b.keyPath));
  return rows;
}