ThemeExtension<T extends ThemeExtension<T>> class Null safety

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.
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.
read-onlyinherited
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
type Object
The extension's type.
read-only

Methods

copyWith() ThemeExtension<T>
Creates a copy of this theme extension with the given fields replaced by the non-null parameter values.
lerp(ThemeExtension<T>? other, double t) ThemeExtension<T>
Linearly interpolate with another ThemeExtension object.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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