encodeObjectList<T> method

String? encodeObjectList<T>(
  1. List<T>? list,
  2. Map<String, dynamic> toJson(
    1. T
    )
)

Implementation

String? encodeObjectList<T>(List<T>? list, Map<String, dynamic> Function(T) toJson) {
 if (list == null || list.isEmpty) return null;
 try {
   final encoded = list.map((item) => toJson(item)).toList();
   return json.encode(encoded);
 } catch (e) {
   logger.e('JsonUtils encodeObjectList error: $e');
   return null;
 }
  }