2023-04-18 00:15:29 +08:00
|
|
|
import 'package:to_string/to_string.dart';
|
|
|
|
|
|
|
|
part 'or_null.g.dart';
|
|
|
|
|
2021-04-29 03:22:33 +08:00
|
|
|
/// To hold optional arguments that themselves could be null
|
2023-04-18 00:15:29 +08:00
|
|
|
@toString
|
2021-04-29 03:22:33 +08:00
|
|
|
class OrNull<T> {
|
2023-08-24 23:31:52 +08:00
|
|
|
const OrNull(this.obj);
|
2021-04-29 03:22:33 +08:00
|
|
|
|
2021-07-24 04:05:57 +08: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-29 01:15:09 +08:00
|
|
|
|
2023-04-18 00:15:29 +08:00
|
|
|
@override
|
|
|
|
String toString() => _$toString();
|
|
|
|
|
2021-07-24 04:05:57 +08:00
|
|
|
final T? obj;
|
2021-04-29 03:22:33 +08:00
|
|
|
}
|