mergeTwoMaps function

dynamic mergeTwoMaps(
  1. dynamic a,
  2. dynamic b
)
  • merges to maps into single one
  • if the key found in both maps it will use the one from the second map

Implementation

// Map<Object, Object?>? mergeTwoMaps(Object? a, Object? b) {
//   if (a is Map<Object, Object?> && b is Map<Object, Object?>) {
//     return mergeMaps<Object, Object?>(a, b, value: mergeTwoMaps);
//   } else if (b is Map<Object, Object?>) {
//     return b;
//   }

//   throw Exception('mergeTwoMaps: invalid types');
// }
dynamic mergeTwoMaps(dynamic a, dynamic b) {
  if (a is Map<String, Object?> && b is Map<String, Object?>) {
    return mergeMaps<String, dynamic>(a, b, value: mergeTwoMaps);
  }
  return b;
}