implemented new loadable state concept
This commit is contained in:
@ -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;
|
||||
}
|
Reference in New Issue
Block a user