Skip to content

Instantly share code, notes, and snippets.

@priezz
Created December 23, 2022 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save priezz/7113e665fee1dda2f9152cae0c780fb5 to your computer and use it in GitHub Desktop.
Save priezz/7113e665fee1dda2f9152cae0c780fb5 to your computer and use it in GitHub Desktop.
null checks
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