Props class

A typed wrapper for component props that provides convenient accessors.

Example

@override
void connectedCallback() {
  final props = Props.decode(prop('data'));
  final name = props.getString('name');
  final count = props.getInt('count');
  final items = props.getList<String>('items');
}

Constructors

Props(Map<String, dynamic> _data)
Creates a Props instance from a decoded map.
const
Props.decode(String encoded)
Creates a Props instance by decoding a base64-encoded JSON string.
factory
Props.empty()
Creates an empty Props instance.
const

Properties

data Map<String, dynamic>
Returns the underlying map.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

get(String key) → dynamic
Gets a raw value by key.
getBool(String key, [bool defaultValue = false]) bool
Gets a bool value.
getDouble(String key, [double defaultValue = 0.0]) double
Gets a double value.
getInt(String key, [int defaultValue = 0]) int
Gets an int value.
getList<T>(String key) List<T>
Gets a List value.
getMap(String key) Map<String, dynamic>
Gets a nested Map value.
getNested(String key) Props
Gets a nested Props value.
getString(String key, [String defaultValue = '']) String
Gets a String value.
has(String key) bool
Checks if the props contain a key.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

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