PlaceholderText.from constructor

const PlaceholderText.from({
  1. Key? key,
  2. required Widget childBuilder(
    1. BuildContext
    ),
  3. PlaceholderState? forceState,
  4. required bool isEmpty,
  5. required bool isLoading,
  6. String? errorText,
  7. void onRefresh()?,
  8. void onRetryForNothing()?,
  9. void onRetryForError()?,
  10. PlaceholderStateChangedCallback? onChanged,
  11. PlaceholderSetting? setting,
  12. 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,
      );