serialize method Null safety

Iterable<Map<String, Object?>> serialize(
  1. MenuItem group,
  2. PlatformMenuDelegate delegate,
  3. {required MenuItemSerializableIdGenerator getId}
)

Converts the supplied object to the correct channel representation for the 'flutter/menu' channel.

This API is supplied so that implementers of PlatformMenuItemGroup can share this implementation.

Implementation

static Iterable<Map<String, Object?>> serialize(
  MenuItem group,
  PlatformMenuDelegate delegate, {
  required MenuItemSerializableIdGenerator getId,
}) {
  final List<Map<String, Object?>> result = <Map<String, Object?>>[];
  result.add(<String, Object?>{
    _kIdKey: getId(group),
    _kIsDividerKey: true,
  });
  for (final MenuItem item in group.members) {
    result.addAll(item.toChannelRepresentation(
      delegate,
      getId: getId,
    ));
  }
  result.add(<String, Object?>{
    _kIdKey: getId(group),
    _kIsDividerKey: true,
  });
  return result;
}