encode method Null safety

  1. @mustCallSuper
void encode(
  1. KeyedArchive object
)
@mustCallSuper, override

Implementation

@mustCallSuper
void encode(KeyedArchive object) {
  final invalidKeys = extensions.keys
      .where((key) => !key.startsWith("x-"))
      .map((key) => "'$key'")
      .toList();
  if (invalidKeys.length > 0) {
    throw new ArgumentError(
        "extension keys must start with 'x-'. The following keys are invalid: ${invalidKeys.join(", ")}");
  }

  extensions.forEach((key, value) {
    object.encode(key, value);
  });
}