getMenuValues method

  1. @protected
List<Map<String, dynamic>> getMenuValues(
  1. dynamic values,
  2. String nameKey,
  3. String valueKey
)

Implementation

@protected
List<Map<String, dynamic>> getMenuValues(
    dynamic values, String nameKey, String valueKey) {
  final valueList = <Map<String, dynamic>>[];
  if (values is String) {
    final valueSplit = values.split("|");
    for (var val in valueSplit) {
      valueList.add({
        nameKey: val,
        valueKey: val,
      });
    }
  } else if (values is List) {
    for (var val in values) {
      if (val is Map) {
        valueList.add({
          nameKey: val[nameKey] ?? val[valueKey],
          valueKey: val[valueKey],
        });
      } else if (val is String) {
        valueList.add({
          nameKey: val,
          valueKey: val,
        });
      }
    }
  }
  return valueList;
}