-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cast_utils.dart (castAsOrNull, castAsNullable)
- Loading branch information
1 parent
0a96fc7
commit d976e39
Showing
3 changed files
with
8 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/// Future compat to always return nullable. | ||
T? castAsNullable<T extends Object>(T? value) => value; | ||
T? castAsNullable<T extends Object?>(T? value) => value; | ||
|
||
/// Safe cast | ||
T? castAsOrNull<T extends Object>(Object? object) => | ||
T? castAsOrNull<T extends Object?>(Object? object) => | ||
object is T ? object : null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters