resolveFiledName method

String? resolveFiledName(
  1. List<String> fieldsNames,
  2. String fieldName, {
  3. Map<String, int>? fieldsNamesIndexes,
  4. List<String>? fieldsNamesLC,
  5. List<String>? fieldsNamesSimple,
  6. bool includeAbsentFields = false,
  7. List<String>? returnMapUsedKeys,
})
inherited

Resolves fieldName to one that matches a fieldsNames element.

Implementation

String? resolveFiledName(
  List<String> fieldsNames,
  final String fieldName, {
  Map<String, int>? fieldsNamesIndexes,
  List<String>? fieldsNamesLC,
  List<String>? fieldsNamesSimple,
  bool includeAbsentFields = false,
  List<String>? returnMapUsedKeys,
}) {
  var f = fieldsNames.firstWhereOrNull((f) => f == fieldName);

  f ??= fieldsNames.firstWhereOrNull((f) {
    String? fLC, fSimple;
    if (fieldsNamesIndexes != null) {
      var idx = fieldsNamesIndexes[f]!;
      fLC = fieldsNamesLC?[idx];
      fSimple = fieldsNamesSimple?[idx];
    }

    fLC ??= fieldToLCKey(f);
    if (fieldName == fLC) return true;

    fSimple ??= fieldToSimpleKey(f);
    if (fieldName == fSimple) return true;

    return false;
  });

  return f;
}