implemented new loadable state concept

This commit is contained in:
2024-05-05 22:58:40 +02:00
parent f58a2ec8cd
commit 6ad8203b6a
31 changed files with 1085 additions and 214 deletions

View File

@ -0,0 +1,18 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'loadable_state.freezed.dart';
@freezed
class LoadableState<TState> with _$LoadableState {
const LoadableState._();
const factory LoadableState({
@Default(true) bool isLoading,
@Default(null) TState? data,
}) = _LoadableState;
bool showPrimaryLoading() => isLoading && data == null;
bool showBackgroundLoading() => isLoading && data != null;
bool showError() => !isLoading && data == null;
bool showContent() => data != null;
}