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
+9
View File
@@ -0,0 +1,9 @@
extension DurationX on Duration {
String formatTimeZoneOffset() {
final hours = inHours.abs().toString().padLeft(2, '0');
final minutes = (inMinutes.abs() % 60).toString().padLeft(2, '0');
final sign = isNegative ? '-' : '+';
return '$sign$hours$minutes';
}
}
+4 -4
View File
@@ -1,12 +1,12 @@
import 'dart:ui';
import 'package:xxh3/xxh3.dart';
import 'package:fast_equatable/hash.dart';
extension ImageHash on Image {
Future<int?> calculateHash() async {
final bytes = await toByteData();
if (bytes != null) {
final digest = xxh3(bytes.buffer.asUint8List());
final byteData = await toByteData();
if (byteData != null) {
final digest = secureHash(byteData);
return digest;
}
+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;
}
+3
View File
@@ -0,0 +1,3 @@
extension UriX on Uri {
Uri get base => Uri.parse('$scheme://$authority');
}