addWhenNotNull static method

void addWhenNotNull(
  1. Map<String, dynamic> json,
  2. String key,
  3. dynamic value
)

Adds a key-value pair to a JSON map if the value is not null. If the value is null, no key-value pair is added.

Implementation

static void addWhenNotNull(
    Map<String, dynamic> json, String key, dynamic value) {
  if (value == null) return;
  json[key] = value;
}