convert

open override fun convert(content: String, iconName: String, config: ParserConfig, fileType: FileType, optimizer: ContentOptimizer?): Flow<ConversionStep>(source)

Converts vector icon content into Kotlin Compose code by processing it through optimization, parsing, and code generation stages.

This function emits conversion progress steps through a Flow, allowing consumers to track the conversion process. The conversion pipeline includes optional optimization of the input content, parsing the vector format into an intermediate representation, and generating the final Kotlin code for Compose ImageVector.

The conversion process follows these stages:

  1. Optimizing (optional) - if an optimizer is provided, the content is optimized

  2. Parsing - the vector content is parsed according to the file type

  3. Generating - Kotlin code is generated from the parsed icon

  4. Complete - emits the final conversion result

If any error occurs during the conversion process, an Error step is emitted containing the exception details.

Return

a Flow of ConversionStep instances representing the progress and result of the conversion

Parameters

content

the raw string content of the vector icon file

iconName

the name to be used for the generated icon in Kotlin code

config

the parser configuration containing package name, theme, and other generation options

fileType

the type of vector file being converted (defaults to SVG)

optimizer

optional optimizer to preprocess the content before parsing