toBuilderMap method
Serializes this configuration into a map with two keys — 'viewState'
and 'topLevel' — consumed by WebConfigurationBuilder.
This indirection lets nutrient_flutter_web consume WebViewConfiguration
data without importing nutrient_flutter directly.
Implementation
Map<String, dynamic> toBuilderMap() {
final viewState = <String, dynamic>{};
final topLevel = <String, dynamic>{};
// initialViewState properties
if (showToolbar != null) viewState['showToolbar'] = showToolbar;
if (showAnnotations != null) viewState['showAnnotations'] = showAnnotations;
if (showAnnotationNotes != null) {
viewState['showAnnotationNotes'] = showAnnotationNotes;
}
if (showComments != null) viewState['showComments'] = showComments;
if (readOnly != null) viewState['readOnly'] = readOnly;
if (enableAnnotationToolbar != null) {
viewState['enableAnnotationToolbar'] = enableAnnotationToolbar;
}
if (sidebarMode != null) {
viewState['sidebarMode'] = switch (sidebarMode!) {
SidebarMode.annotations => 'ANNOTATIONS',
SidebarMode.bookmarks => 'BOOKMARKS',
SidebarMode.thumbnails => 'THUMBNAILS',
SidebarMode.documentOutline => 'DOCUMENT_OUTLINE',
SidebarMode.custom => 'CUSTOM',
};
}
if (interactionMode != null) {
viewState['interactionMode'] = interactionMode!.webName;
}
if (zoom != null) viewState['zoom'] = zoom;
if (zoomStep != null) viewState['zoomStep'] = zoomStep;
if (spreadSpacing != null) viewState['spreadSpacing'] = spreadSpacing;
if (pageSpacing != null) viewState['pageSpacing'] = pageSpacing;
if (viewportPadding != null) viewState['viewportPadding'] = viewportPadding;
if (allowPrinting != null) viewState['allowPrinting'] = allowPrinting;
if (canScrollWhileDrawing != null) {
viewState['canScrollWhileDrawing'] = canScrollWhileDrawing;
}
if (keepFirstSpreadAsSinglePage != null) {
viewState['keepFirstSpreadAsSinglePage'] = keepFirstSpreadAsSinglePage;
}
if (keepSelectedTool != null) {
viewState['keepSelectedTool'] = keepSelectedTool;
}
if (formDesignMode != null) viewState['formDesignMode'] = formDesignMode;
if (previewRedactionMode != null) {
viewState['previewRedactionMode'] = previewRedactionMode;
}
if (showSignatureValidationStatus != null) {
viewState['showSignatureValidationStatus'] =
showSignatureValidationStatus!.webName;
}
if (pageRotation != null) viewState['pagesRotation'] = pageRotation;
// Top-level properties
if (password != null) topLevel['password'] = password;
if (theme != null) topLevel['theme'] = theme;
if (autoSaveMode != null) topLevel['autoSaveMode'] = autoSaveMode!.webName;
if (disableTextSelection != null) {
topLevel['disableTextSelection'] = disableTextSelection;
}
if (disableForms != null) topLevel['disableForms'] = disableForms;
if (disableHighQualityPrinting != null) {
topLevel['disableHighQualityPrinting'] = disableHighQualityPrinting;
}
if (disableMultiSelection != null) {
topLevel['disableMultiSelection'] = disableMultiSelection;
}
if (disableOpenParameters != null) {
topLevel['disableOpenParameters'] = disableOpenParameters;
}
if (disableWebAssemblyStreaming != null) {
topLevel['disableWebAssemblyStreaming'] = disableWebAssemblyStreaming;
}
if (minDefaultZoomLevel != null) {
topLevel['minDefaultZoomLevel'] = minDefaultZoomLevel;
}
if (maxDefaultZoomLevel != null) {
topLevel['maxDefaultZoomLevel'] = maxDefaultZoomLevel;
}
if (headless != null) topLevel['headless'] = headless;
if (locale != null) topLevel['locale'] = locale;
if (toolbarPlacement != null) {
topLevel['toolbarPlacement'] = toolbarPlacement!.webName;
}
if (styleSheets != null) topLevel['styleSheets'] = styleSheets;
if (editableAnnotationTypes != null) {
topLevel['editableAnnotationTypes'] = editableAnnotationTypes;
}
if (enableHistory != null) topLevel['enableHistory'] = enableHistory;
if (enableAutomaticLinkExtraction != null) {
topLevel['enableAutomaticLinkExtraction'] = enableAutomaticLinkExtraction;
}
if (enableClipboardActions != null) {
topLevel['enableClipboardActions'] = enableClipboardActions;
}
if (enableServiceWorkerSupport != null) {
topLevel['enableServiceWorkerSupport'] = enableServiceWorkerSupport;
}
if (preventTextCopy != null) topLevel['preventTextCopy'] = preventTextCopy;
if (restrictAnnotationToPageBounds != null) {
topLevel['restrictAnnotationToPageBounds'] =
restrictAnnotationToPageBounds;
}
if (autoCloseThreshold != null) {
topLevel['autoCloseThreshold'] = autoCloseThreshold;
}
if (overrideMemoryLimit != null) {
topLevel['overrideMemoryLimit'] = overrideMemoryLimit;
}
if (standaloneInstancesPoolSize != null) {
topLevel['standaloneInstancesPoolSize'] = standaloneInstancesPoolSize;
}
if (maxPasswordRetries != null) {
topLevel['maxPasswordRetries'] = maxPasswordRetries;
}
if (maxMentionSuggestions != null) {
topLevel['maxMentionSuggestions'] = maxMentionSuggestions;
}
if (customFonts != null) topLevel['customFonts'] = customFonts;
if (stampAnnotationTemplates != null) {
topLevel['stampAnnotationTemplates'] = stampAnnotationTemplates;
}
if (formFieldsNotSavingSignatures != null) {
topLevel['formFieldsNotSavingSignatures'] = formFieldsNotSavingSignatures;
}
if (mentionableUsers != null) {
topLevel['mentionableUsers'] = mentionableUsers;
}
if (documentEditorFooterItems != null) {
topLevel['documentEditorFooterItems'] = documentEditorFooterItems;
}
if (documentEditorToolbarItems != null) {
topLevel['documentEditorToolbarItems'] = documentEditorToolbarItems;
}
if (printOptions != null) topLevel['printOptions'] = printOptions;
if (baseCoreUrl != null) topLevel['baseCoreUrl'] = baseCoreUrl;
if (baseUrl != null) topLevel['baseUrl'] = baseUrl;
if (useCDN != null) topLevel['useCDN'] = useCDN;
if (container != null) topLevel['container'] = container;
if (xfdf != null) topLevel['xfdf'] = xfdf;
if (xfdfKeepCurrentAnnotations != null) {
topLevel['xfdfKeepCurrentAnnotations'] = xfdfKeepCurrentAnnotations;
}
if (officeConversionSettings != null) {
topLevel.addAll(officeConversionSettings!.toMap());
}
if (toolbarItems != null) topLevel['toolbarItems'] = toolbarItems;
if (annotationToolbarItems != null) {
topLevel['annotationToolbarItems'] = annotationToolbarItems;
}
if (customRenderers != null) topLevel['customRenderers'] = customRenderers;
if (customUIConfiguration != null) {
topLevel['customUIConfiguration'] = customUIConfiguration;
}
if (electronicSignatures != null) {
topLevel['electronicSignatures'] = electronicSignatures;
}
return {'viewState': viewState, 'topLevel': topLevel};
}