toJson method

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  final hasNewInterceptionConfig = interceptAllAnnotationActions != null ||
      interceptAnnotationActions != null;
  final effectiveInterceptAllAnnotationActions =
      interceptAllAnnotationActions ?? false;
  final effectiveInterceptAnnotationActions = interceptAnnotationActions ??
      [
        if (interceptNoteAction) CPDFAnnotationType.note,
        if (interceptLinkAction) CPDFAnnotationType.link,
      ];

  return {
    'availableTypes': availableTypes.map((e) => e.name).toList(),
    'availableTools': availableTools.map((e) => e.name).toList(),
    'initAttribute': initAttribute.toJson(),
    'annotationAuthor': annotationAuthor,
    'inkUndoRedoMode': inkUndoRedoMode.name,
    'autoShowSignPicker': autoShowSignPicker,
    'autoShowPicPicker': autoShowPicPicker,
    'autoShowStampPicker': autoShowStampPicker,
    'autoShowLinkDialog': autoShowLinkDialog,
    'autoShowNoteEditDialog': autoShowNoteEditDialog,
    'interceptNoteAction': interceptNoteAction,
    'interceptLinkAction': interceptLinkAction,
    if (hasNewInterceptionConfig) ...{
      'interceptAllAnnotationActions': effectiveInterceptAllAnnotationActions,
      'interceptAnnotationActions':
          effectiveInterceptAnnotationActions.map((e) => e.name).toList(),
    },
  };
}