Option<T>.safeCast constructor
Option<T>.safeCast (
- dynamic value
Safely cast a value to type T.
If value is not of type T, then return a None.
Less strict version of Option.safeCastStrict, since safeCast
assumes the value to be dynamic.
Note: Make sure to specify the type of Option (Option<T>.safeCast
instead of Option.safeCast), otherwise this will always return Some!
Implementation
// `dynamic`s are use for safe-casting
//ignore: avoid_annotating_with_dynamic
factory Option.safeCast(dynamic value) =>
Option.safeCastStrict<T, dynamic>(value);