Skip to content

Define ColorSwatch.lerp() function  #103695

@davidmigloz

Description

@davidmigloz

Use case

ThemeExtension has been added as a way to support custom colors or theme properties (ref: #31522).
It forces you to implement lerp() method which is used to linearly interpolate between two ThemeExtension.
A lot of classes already define their own lerp function like Size.lerp, Color.lerp, RRect.lerp, Radius.lerp, etc.

A common way of defining related colors in custom themes is using a ColorSwatch. However, it does not define its own lerp() function at the moment, what makes implement ThemeExtension.lerp() function a difficult task.

Proposal

Define a static lerp() function for ColorSwatch:

static ColorSwatch<T>? lerp<T>(ColorSwatch<T>? a, ColorSwatch<T>? b, double t)

It could delegate in Color.lerp() for every color in the swatch table.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions