filterByKeys<T, K> method

Map<T, K> filterByKeys<T, K>({
  1. required List<String> keys,
  2. bool isAllowValueNull = true,
})

Implementation

Map<T, K> filterByKeys<T, K>({
  required List<String> keys,
  bool isAllowValueNull = true,
}) {
  Map<T, K> jsonData = {};

  forEach((key, value) {
    if (keys.contains(key)) {
      if (isAllowValueNull) {
        jsonData[key] = value;
      } else {
        if (value != null) {
          jsonData[key] = value;
        }
      }
    }
  });
  return jsonData;
}