You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tas<T>(dynamic it) => it isT? it :null; // that's what I used for a long time.test('should as<T>()', () async {
constdynamic it ="Hello";
expect(as<String>(it) ??"", "Hello");
expect(as<int>(it) ??0, 0);
const nullIt =null;
expect(as<String>(nullIt) ??"", "");
});
I tried to implement it with the following code, but they don't work, I think it's a limitation in Dart:
The text was updated successfully, but these errors were encountered:
yongjhih
changed the title
Add an Object.as() for null-safety casting similar to as? in Kotlin
Add an as() for null-safety casting similar to as? in Kotlin
Jan 13, 2020
I tried to implement it with the following code, but they don't work, I think it's a limitation in Dart:
or
The text was updated successfully, but these errors were encountered: