majro update
This commit is contained in:
@@ -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';
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
extension UriX on Uri {
|
||||
Uri get base => Uri.parse('$scheme://$authority');
|
||||
}
|
||||
Reference in New Issue
Block a user