mirror of
https://github.com/hanskokx/arcane_helper_utils.git
synced 2026-05-14 10:29:07 +02:00
v1.3.1
This commit is contained in:
@@ -44,3 +44,41 @@ extension Unique<E, Id> on List<E> {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
/// An extension on nullable `List` to provide convenience methods for checking nullability and emptiness.
|
||||
///
|
||||
/// This extension adds getters that make it easier to check if a list is null,
|
||||
/// empty, or both in a single operation.
|
||||
extension ListNullability on List? {
|
||||
/// Returns `true` if the list is either not null and not empty.
|
||||
///
|
||||
/// This is the inverse of [isNullOrEmpty].
|
||||
///
|
||||
/// Example usage:
|
||||
/// ```dart
|
||||
/// List<int>? list = [1, 2, 3];
|
||||
/// print(list.isNotNullOrEmpty); // Output: true
|
||||
///
|
||||
/// list = [];
|
||||
/// print(list.isNotNullOrEmpty); // Output: false
|
||||
///
|
||||
/// list = null;
|
||||
/// print(list.isNotNullOrEmpty); // Output: false
|
||||
/// ```
|
||||
bool get isNotNullOrEmpty => !isNullOrEmpty;
|
||||
|
||||
/// Returns `true` if the list is either null or empty.
|
||||
///
|
||||
/// Example usage:
|
||||
/// ```dart
|
||||
/// List<int>? list = null;
|
||||
/// print(list.isNullOrEmpty); // Output: true
|
||||
///
|
||||
/// list = [];
|
||||
/// print(list.isNullOrEmpty); // Output: true
|
||||
///
|
||||
/// list = [1, 2, 3];
|
||||
/// print(list.isNullOrEmpty); // Output: false
|
||||
/// ```
|
||||
bool get isNullOrEmpty => this == null || this!.isEmpty;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class Ticker {
|
||||
required Duration timeout,
|
||||
Duration interval = const Duration(seconds: 1),
|
||||
}) {
|
||||
final int ticks = timeout.inSeconds ~/ interval.inSeconds;
|
||||
final int ticks = timeout.inMicroseconds ~/ interval.inMicroseconds;
|
||||
return Stream.periodic(interval, (x) => ticks - x - 1).take(ticks);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user