Skip to content

[Enhancement] Lazy properties in code output #63

Description

Description
Instead of generating a custom singleton pattern for every icon, we could use the built-in lazy functionality.
For example:

val ArrowLeft: ImageVector
    get() {
        if (_ArrowLeft != null) {
            return _ArrowLeft!!
        }
        _ArrowLeft = ImageVector.Builder(....).build()

        return _ArrowLeft!!
    }

private var _ArrowLeft: ImageVector? = null

becomes

val ArrowLeft: ImageVector by lazy {
     ImageVector.Builder(....).build()
}

A minor thing to be sure but it does:

  1. Reduce indentation by one level
  2. Make the singleton pattern clearer
  3. Reduce the lines of code by 8 / per file which across something like 300 icons becomes significant

P.S. Love the plugin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions