main
1/// Extension for safer casting of generic objects.
2extension Castable on Object {
3 /// Returns null if this is not of type [T] else return casted object.
4 T? castOrNull<T>() {
5 if (this is T) return this as T;
6 return null;
7 }
8}