lookupMap method

Map<String, List<String>> lookupMap(
  1. String keyField,
  2. List<String> cols
)

Implementation

Map<String, List<String>> lookupMap(String keyField, List<String> cols) {
  final m = <String, List<String>>{};
  if (!active) return m;
  final bm = getBookmark();
  disableControls();
  try {
    first();
    while (!eof) {
      final k = (findField(keyField)?.asString ?? '').trim();
      if (k.isNotEmpty) {
        m[k] = [
          for (final c in cols) (findField(c)?.asString ?? '').trim()
        ];
      }
      next();
    }
  } finally {
    if (bm != null && bookmarkValid(bm)) gotoBookmark(bm);
    enableControls();
  }
  return m;
}