sortedJson method

Map<String, dynamic> sortedJson({
  1. bool includeNulls = false,
})

Returns a Json i.e. Map<String, dynamic> representation of the BaseModel, with the keys sorted alphabetically.

Implementation

Map<String, dynamic> sortedJson({
  bool includeNulls = false,
}) {
  final a = toJson(includeNulls: includeNulls);
  final b = a.keys.toList(growable: false)
    ..sort((k1, k2) => k1.compareTo(k2));
  final c = {for (var k in b) k: a[k] as dynamic};
  return c;
}