mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: use cascade (#812)
This commit is contained in:
committed by
GitHub
parent
877732e1e7
commit
6f69a45195
@@ -14,6 +14,11 @@ sealed class LoadingState<T> {
|
||||
Error() => throw this,
|
||||
Loading() => throw Exception('ApiException: loading'),
|
||||
};
|
||||
|
||||
T? get dataOrNull => switch (this) {
|
||||
Success(response: final res) => res,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
class Loading extends LoadingState<Never> {
|
||||
|
||||
Reference in New Issue
Block a user