encode static method
Encodes form (parsed by DartRosa's XFormParser).
Implementation
static Uint8List encode(FormDef form) {
final sourceXml = form.sourceXml;
if (sourceXml == null) {
throw StateError('The form has no source XML (not parsed from XML)');
}
return Uint8List.fromList(
utf8.encode(
jsonEncode({
'version': version,
'formXml': sourceXml,
'formXmlPath': form.formXmlPath,
'lastSavedSrc': form.lastSavedSrc,
'instance': XFormSerializingVisitor(
respectRelevance: false,
).serializeInstanceToString(form.mainInstance),
'language': form.localizer?.locale,
}),
),
);
}