encodeList<T> static method

void encodeList<T>(
  1. Map<String, dynamic> json,
  2. String key,
  3. List<T> list,
  4. Map<String, dynamic> toJson(
    1. T
    ),
)

Encodes a list to a JSON map if not empty.

Implementation

static void encodeList<T>(
  Map<String, dynamic> json,
  String key,
  List<T> list,
  Map<String, dynamic> Function(T) toJson,
) {
  if (list.isNotEmpty) {
    json[key] = list.map(toJson).toList();
  }
}