Encodes this mutation as JSON-compatible data.
Map<String, Object?> toJson() => <String, Object?>{ 'key': key.toJson(), 'state': state, if (scope != null) 'scope': scope, if (meta.isNotEmpty) 'meta': meta, };