getPayload<T> method
T?
getPayload<T>()
Gets the payload cast to a specific type.
Returns the payload cast to type T
if it's compatible,
otherwise returns null.
Example:
final user = result.getPayload<User>();
if (user != null) {
print('User: ${user.name}');
}
Type parameter T
: The expected payload type
Returns the payload as T
or null if not compatible
Implementation
T? getPayload<T>() {
if (payload is T) {
return payload as T;
}
return null;
}