2023-04-17 18:15:29 +02:00
|
|
|
import 'package:to_string/to_string.dart';
|
|
|
|
|
|
|
|
part 'or_null.g.dart';
|
|
|
|
|
2021-04-28 21:22:33 +02:00
|
|
|
/// To hold optional arguments that themselves could be null
|
2023-04-17 18:15:29 +02:00
|
|
|
@toString
|
2021-04-28 21:22:33 +02:00
|
|
|
class OrNull<T> {
|
|
|
|
OrNull(this.obj);
|
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
/// Return iff the value of [x] is set to null, which means if [x] itself is
|
|
|
|
/// null, false will still be returned
|
|
|
|
static bool isSetNull(OrNull? x) => x != null && x.obj == null;
|
2021-05-28 19:15:09 +02:00
|
|
|
|
2023-04-17 18:15:29 +02:00
|
|
|
@override
|
|
|
|
String toString() => _$toString();
|
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
final T? obj;
|
2021-04-28 21:22:33 +02:00
|
|
|
}
|