PlaceholderText.from constructor
const
PlaceholderText.from({
- Key? key,
- required Widget childBuilder(),
- PlaceholderState? forceState,
- required bool isEmpty,
- required bool isLoading,
- String? errorText,
- void onRefresh()?,
- void onRetryForNothing()?,
- void onRetryForError()?,
- PlaceholderStateChangedCallback? onChanged,
- PlaceholderSetting? setting,
- PlaceholderDisplayRule displayRule = PlaceholderDisplayRule.dataFirst,
Creates PlaceholderText with given parameters, this constructor uses given fields and
displayRule
to get the state.
Implementation
const PlaceholderText.from({
Key? key,
required Widget Function(BuildContext) childBuilder,
PlaceholderState? forceState,
required bool isEmpty,
required bool isLoading,
String? errorText,
void Function()? onRefresh,
void Function()? onRetryForNothing,
void Function()? onRetryForError,
PlaceholderStateChangedCallback? onChanged,
PlaceholderSetting? setting,
PlaceholderDisplayRule displayRule = PlaceholderDisplayRule.dataFirst,
}) : this(
key: key,
childBuilder: childBuilder,
state: forceState ?? // use given forced state
(displayRule == PlaceholderDisplayRule.dataFirst
?
// dataFirst
(isEmpty == false
? PlaceholderState.normal // !empty => normal
: isLoading == true
? PlaceholderState.loading // empty && loading => loading
: errorText != null && errorText != ''
? PlaceholderState.error // empty && !loading && error => error
: PlaceholderState.nothing) // empty && !loading && !error => nothing
: displayRule == PlaceholderDisplayRule.loadingFirst
?
// loadingFirst
(isLoading == true
? PlaceholderState.loading // loading => loading
: isEmpty == false
? PlaceholderState.normal // !loading && !empty => normal
: errorText != null && errorText != ''
? PlaceholderState.error // !loading && empty && error => error
: PlaceholderState.nothing) // !loading && empty && !error => nothing
:
// errorFirst
(isLoading == true
? PlaceholderState.loading // loading => loading
: errorText != null && errorText != ''
? PlaceholderState.error // !loading && error => error
: isEmpty == false
? PlaceholderState.normal // !loading && !error && !empty => normal
: PlaceholderState.nothing) // !loading && !error && empty => nothing
),
errorText: errorText,
onRefresh: onRefresh,
onRetryForNothing: onRetryForNothing,
onRetryForError: onRetryForError,
onChanged: onChanged,
setting: setting,
);