I have a dynamic x and I would like to assign x to T s if x is T, and otherwise assign null to s. S
dynamic x
x
T s
x is T
null
s
A combination of both prior two posts, without the logging.
Fallback defaults to null when not provided.
T cast(dynamic x, {T fallback}) => x is T ? x : fallback;