MorphTheme class
Ambient engine defaults as a ThemeExtension: "how this app morphs", declared once instead of being threaded through every call site.
Resolution order everywhere is: explicit parameter > MorphTheme > built-in default. Every field is nullable so partial themes compose (a subtree can override just the motion, inheriting the rest).
MaterialApp(
theme: ThemeData(
extensions: const <ThemeExtension<Object?>>[
MorphTheme(motion: MorphMotion.fast, skinStyle: MorphSkinStyle.goo),
],
),
)
Note the scope of this class: it holds ENGINE defaults (motion, landing bump, scrim, liquid knobs). An app's surface vocabulary (pill/card/fab specs) belongs in the app's own ThemeExtension as MorphSurfaceSpec values - the engine cannot know those names.
- Inheritance
-
- Object
- ThemeExtension<
MorphTheme> - MorphTheme
- Annotations
Constructors
- MorphTheme({MorphMotion? motion, double? bumpScale, double? bumpRecoil, double? maxScrimOpacity, Color? scrimColor, Color? shadowColor, MorphSkinStyle? skinStyle})
-
Creates the extension; null fields fall through to built-ins.
const
Properties
- bumpRecoil → double?
-
Default landing kick-off distance in px.
final
- bumpScale → double?
-
Default landing-bump knobs for MorphTags that do not declare
their own.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- maxScrimOpacity → double?
-
Default scrim ceiling for flights.
final
- motion → MorphMotion?
-
The default motion profile for flights launched without an
explicit
motion.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrimColor → Color?
-
Default scrim color for flights (black when unset).
final
- shadowColor → Color?
-
Default shadow color, applied verbatim - its opacity is part of
the value.
final
- skinStyle → MorphSkinStyle?
-
Default knob bundle for MorphSkins without a style or explicit
knobs.
final
- type → Object
-
The extension's type.
no setterinherited
Methods
-
copyWith(
{MorphMotion? motion, double? bumpScale, double? bumpRecoil, double? maxScrimOpacity, Color? scrimColor, Color? shadowColor, MorphSkinStyle? skinStyle}) → MorphTheme -
Creates a copy of this theme extension with the given fields
replaced by the non-null parameter values.
override
-
lerp(
covariant MorphTheme? other, double t) → MorphTheme -
Linearly interpolate with another ThemeExtension object.
override
-
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.
override
Static Methods
-
maybeOf(
BuildContext context) → MorphTheme? - The extension from the ambient ThemeData, if installed.