ThemeExtension<T extends ThemeExtension<T>> class abstract

An interface that defines custom additions to a ThemeData object.

Typically used for custom colors. To use, subclass ThemeExtension, define a number of fields (e.g. Colors), and implement the copyWith and lerp methods. The latter will ensure smooth transitions of properties when switching themes.

This sample shows how to create and use a subclass of ThemeExtension that defines two colors.
link

To create a local project with this code sample, run:
flutter create --sample=material.ThemeExtension.1 mysample

Constructors

ThemeExtension()
Enable const constructor for subclasses.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type Object
The extension's type.
no setter

Methods

copyWith() ThemeExtension<T>
Creates a copy of this theme extension with the given fields replaced by the non-null parameter values.
lerp(covariant ThemeExtension<T>? other, double t) ThemeExtension<T>
Linearly interpolate with another ThemeExtension object.
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