Style class

A utility class for managing a collection of styling attributes and variants.

The Style class is used to encapsulate a set of styling attributes and variants which can be applied to a widget. This class provides several factory constructors and utility methods to help create, manipulate, and merge collections of styling attributes and variants.

Example:

final style = Style(attribute1, attribute2, attribute3);
final updatedStyle = style.variant(myVariant);
Implementers
Available Extensions

Constructors

Style([Attribute? p1, Attribute? p2, Attribute? p3, Attribute? p4, Attribute? p5, Attribute? p6, Attribute? p7, Attribute? p8, Attribute? p9, Attribute? p10, Attribute? p11, Attribute? p12, Attribute? p13, Attribute? p14, Attribute? p15, Attribute? p16, Attribute? p17, Attribute? p18, Attribute? p19, Attribute? p20])
Creates a new Style instance with a specified list of Attributes.
factory
Style.create(Iterable<Attribute> attributes)
Constructs a Style from an iterable of Attribute instances.
factory
Style.empty()
A constant, empty mix for use with const constructor widgets.
const

Properties

add → SpreadFunctionParams<Attribute, Style>
Allows to create a new Style by using this mix as a base and adding additional attributes.
no setter
applyVariant → SpreadFunctionParams<Variant, Style>
Selects a single or positional params list of Variant and returns a new Style with the selected variants.
no setter
hashCode int
The hash code for this object.
no setterinherited
isAnimated bool
no setter
isEmpty bool
Returns true if this Style does not contain any attributes or variants.
no setter
isNotEmpty bool
Returns false if this Style contains any attributes or variants.
no setter
length int
Returns the length of the list of attributes contained in this mix.
no setter
props List<Object?>
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stringify bool
no setterinherited
styles AttributeMap<StyleAttribute>
Visual attributes contained in this mix.
final
values Iterable<Attribute>
Returns a list of all attributes contained in this mix.
no setter
variants AttributeMap<VariantAttribute<IVariant>>
The variant attributes contained in this mix.
final

Methods

addAll(Iterable<Attribute> attributes) Style
animate({Duration? duration, Curve? curve}) AnimatedStyle
Returns a AnimatedStyle from this Style with the provided duration and curve.
applyVariants(List<Variant> selectedVariants) Style
Selects multiple Variant instances and returns a new Style with the selected variants.
call() NestedStyleAttribute
Returns a new NestedStyleAttribute instance that wraps the current Style instance.
copyWith({AttributeMap<StyleAttribute>? styles, AttributeMap<VariantAttribute<IVariant>>? variants}) Style
Returns a new Style with the provided styles and variants merged with this mix's values.
getDiff(Comparable other) Map<String, String>
inherited
merge(Style? style) Style
Merges this mix with the provided Style instances and returns the resulting Style.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
of(BuildContext context) MixData
pickVariants(List<IVariant> pickedVariants, {bool isRecursive = false}) Style
Picks and applies only the attributes within the specified Variant instances, and returns a new Style.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

combine(Iterable<Style> mixes) Style
Combines a positional list of mixes into a single Style.