ResponsiveValue<T> class

A reusable class-based responsive value.

Useful when the same responsive value is needed in multiple places.

final gridColumns = ResponsiveValue<int>(
  mobile: 2,
  tablet: 3,
  desktop: 4,
);

// Use anywhere:
GridView.count(crossAxisCount: gridColumns.of(context))

Constructors

ResponsiveValue({required T mobile, T? tablet, T? desktop, T? widescreen})
const

Properties

desktop → T?
final
hashCode int
The hash code for this object.
no setterinherited
mobile → T
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tablet → T?
final
widescreen → T?
final

Methods

getValue(BuildContext context) → T
Get value based on current context.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
of(BuildContext context) → T
Get value based on current context. Shorthand for getValue.
toString() String
A string representation of this object.
inherited

Operators

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