majro update

This commit is contained in:
Fabian Freund
2025-02-28 14:30:49 +01:00
parent a8957f6cf8
commit 3c4d479bd9
181 changed files with 7090 additions and 5299 deletions
+22 -3
View File
@@ -1,7 +1,26 @@
extension NullableX<T> on T? {
extension NullableX<T extends Object?> on T? {
@pragma('vm:prefer-inline')
R? mapNotNull<R>(R? Function(T) callback) {
// ignore: null_check_on_nullable_type_parameter validated
return (this != null) ? callback(this!) : null;
// We can simplify this by using the null-aware operator
return this != null ? callback(this as T) : null;
}
}
extension NullableStringX on String? {
@pragma('vm:prefer-inline')
String? get whenNotEmpty => (this?.isNotEmpty ?? false) ? this : null;
@pragma('vm:prefer-inline')
bool get isNotEmpty => this?.isNotEmpty ?? false;
@pragma('vm:prefer-inline')
bool get isEmpty => this?.isEmpty ?? true;
}
extension NullableIterable on Iterable? {
@pragma('vm:prefer-inline')
bool get isNotEmpty => this?.isNotEmpty ?? false;
@pragma('vm:prefer-inline')
bool get isEmpty => this?.isEmpty ?? true;
}