MermaidApi class

Wrapper for methods calls so they can be called from MermaidApi. This more closely matches the docs for the mermaid javascript library. (Note: MermaidApi is used as name instead of mermaidAPI because of Dart naming conventions). In some cases we do not call the underlying mermaidAPI version but instead we call the mermaid version because of inconsistencies in mermaid 9.0.1 mermaidAPI object code and behavior.

Constructors

MermaidApi()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

parseError ← void Function(String error, String hash)
Used to set a handler to be called when invalid diagram syntax is encountered. The definition of the function should match void parseError(String err,String hash). NOTE: As of mermaid version 9.0.1 this method does not exists, but I have submitted a PR that adds this method. The reason for this is that we cannot (from dart interop) add a mermaid.parseError member when none previously existed. (from within javascript this was done simply as mermaid.parseError = function(err,hash) {})
no getter

Static Methods

getConfig() Config
Calls mermaidAPI.getConfig() and returns the current configuration object.
initialize(Config config) → void
Initialize mermaid settings. Pass a configuration object as described in mermaid configation object documentation.
parse(String text) bool
Used to test diagram code before calling render(). Returns true if the diagram syntax is valid. If MermaidApi.parseError or mermaidSetParseErrorHandler have been used to set a parseError() handler then this method will return false if the diagram syntax is invalid. (If no parseError() handler has been set then parse() will throw an exception in javascript as render() would with invalid syntax). NOTE: Note as of mermaid version 9.0.1 the behavior of parse() method has a BUG
render(String? idOfAScratchDivToCreate, String diagramDef, [void bindingCallback(String svgCode, [void bindFunction(Element element)?])?, Element? scratchElementWhereMermaidWillMakeSVG]) String
Used to render a graph and receive have the source for the created SVG file. The complete SVG file will be returned and sent to the bindingCallback if one is provided. The bindingCallback callback only needs to be used if you want to use the bindingCallback to allow mermaid to bind event handlers to the element within the DOM that you are placing the SVG file within. idOfAScratchDivToCreate can be '' or null and this wrapper function will automatically generate random IDs, or it can be a NEVER BEFORE USED html element ID that can use used to create a scratch div (or iframe for sandbox mode). This element will BE REMOVED from the dom before this returns, so DO NOT pass in id's of existing elements. NOTE: This MUST BE a id that was NEVER passed into render() previously - re-using the same scratch ID will not work. diagramDef is the source for the diagram being rendered. bindingCallback is the callback that will be called with the SVG code and binding callback-callback. scratchElementWhereMermaidWillMakeSVG is a scratch div within the dom that mermaid can use. The idOfAScratchDivToCreate must STILL BE a unique ID when using the scratchElementWhereMermaidWillMakeSVG parameter. The underlying JS mermaid library is very peculiar behavior here that I cannot explain.
reset() → void
Resets all configuration and state information to defaults. Calls mermaidApi.reset()