StreamMessageLayoutProperty<T> class abstract

Resolves a value of type T based on a message's StreamMessageLayoutData.

Each field in a message style class (e.g. StreamMessageBubbleStyle.shape) is a StreamMessageLayoutProperty so that its value can vary by alignment (start / end) and stack position (single / top / middle / bottom).

Use the factory constructors for common patterns:

{@tool snippet}

Uniform value for all layouts:

StreamMessageLayoutProperty.all(EdgeInsets.all(12))

{@end-tool}

{@tool snippet}

Alignment-aware color:

StreamMessageLayoutProperty.resolveWith((layout) {
  final isEnd = layout.alignment == StreamMessageAlignment.end;
  return isEnd ? brandColor : surfaceColor;
})

{@end-tool}

{@tool snippet}

Position + alignment aware shape:

StreamMessageLayoutProperty.resolveWith((layout) {
  final isEnd = layout.alignment == StreamMessageAlignment.end;
  return switch (layout.stackPosition) {
    StreamMessageStackPosition.single =>
      RoundedRectangleBorder(borderRadius: BorderRadius.all(r.xxl)),
    StreamMessageStackPosition.top =>
      RoundedRectangleBorder(borderRadius: BorderRadiusDirectional.only(
        topStart: r.xxl,
        topEnd: r.xxl,
        bottomStart: isEnd ? r.xxl : tailRadius,
        bottomEnd: isEnd ? tailRadius : r.xxl,
      )),
    _ => defaultShape,
  };
})

{@end-tool}

See also:

Implementers

Constructors

StreamMessageLayoutProperty()
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

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolve(StreamMessageLayoutData layout) → T
Resolves this property for the given layout.
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

all<T>(T value) → StreamMessageLayoutProperty<T>
Creates a property that returns value for every layout.
lerp<T>(StreamMessageLayoutProperty<T?>? a, StreamMessageLayoutProperty<T?>? b, double t, T? lerpFunction(T?, T?, double)) → StreamMessageLayoutProperty<T?>?
Linearly interpolates between two StreamMessageLayoutProperty values.
resolveWith<T>(T callback(StreamMessageLayoutData layout)) → StreamMessageLayoutProperty<T>
Creates a property that delegates to callback for resolution.