Created with <3 with dartpad.dev.
Created
December 23, 2022 12:24
-
-
Save priezz/7113e665fee1dda2f9152cae0c780fb5 to your computer and use it in GitHub Desktop.
null checks
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
extension on int? { | |
p() => print('int, ${this.runtimeType}'); | |
} | |
extension on Null { | |
p() => print('null'); | |
} | |
const _defaultNull = null; | |
// class Ii implements int {} | |
test({int? a = _defaultNull, int? b = _defaultNull}) { | |
final bool withA = a != _defaultNull; | |
final bool withB = b != _defaultNull; | |
// final bool withA = a is Null; | |
// final bool withB = b is Null; | |
print('a provided: $withA'); | |
print('b provided: $withB'); | |
// _defaultNull.p(); | |
// if (a == null) (a as Null).p(); | |
a.p(); | |
b.p(); | |
// if (b == null) (b as Null).p(); | |
} | |
// copyWith({int? value}) --> copyWith({V<int?>? value} = const V<int?>()) (edited) | |
// white_check_mark | |
// +1 | |
// heavy_check_mark | |
// 10:02 | |
// copyWith();. | |
// copyWith(value: V(10)); | |
// copyWith(value: V(null)); (edited) | |
// 10:04 | |
// copy((b) => b.value = 10); (edited) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment