genUiAsObject function

Map<String, Object?>? genUiAsObject(
  1. Object? value
)

value as a JSON object, or null when it is not a map.

A Map with any key type is rebuilt as a Map<String, Object?>, so a plain Dart map written into the data model by host code reads the same way as one that came from jsonDecode.

Implementation

Map<String, Object?>? genUiAsObject(Object? value) {
  if (value is Map<String, Object?>) return value;
  if (value is Map) {
    return <String, Object?>{
      for (final MapEntry<Object?, Object?> entry in value.entries)
        entry.key.toString(): entry.value,
    };
  }
  return null;
}