PlaceholderManager class

A manager class that allows for globally overriding the loading and error placeholder widgets used throughout the application.

The PlaceholderManager provides static methods to set custom placeholder builders for loading and error states, allowing for a consistent user experience across the app. By default, it uses the standard LoadingPlaceholder and ErrorPlaceholder widgets, but these can be replaced with custom implementations as needed.

Methods:

  • static void setLoadingPlaceholderBuilder(LoadingPlaceholder Function() builder):

    • Sets a custom loading placeholder builder.
    • Parameters:
  • static LoadingPlaceholder getLoadingPlaceholder():

    • Returns the currently set loading placeholder or a default one.
    • Returns: A LoadingPlaceholder widget.
  • static void setErrorPlaceholderBuilder(ErrorPlaceholder Function() builder):

    • Sets a custom error placeholder builder.
    • Parameters:
  • static ErrorPlaceholder getErrorPlaceholder():

    • Returns the currently set error placeholder or a default one.
    • Returns: An ErrorPlaceholder widget.

Usage Example:

Here is an example of how to use the PlaceholderManager class to set custom placeholders in a Flutter application:

void main() {
  // Setting a custom loading placeholder
  PlaceholderManager.setLoadingPlaceholderBuilder(() => CustomLoadingPlaceholder());

  // Setting a custom error placeholder
  PlaceholderManager.setErrorPlaceholderBuilder(() => CustomErrorPlaceholder());

  runApp(MaterialApp(
    home: Scaffold(
      body: Center(
        child: PlaceholderManager.getLoadingPlaceholder(),
      ),
    ),
  ));
}

Note:

Ensure that the custom placeholders implement the necessary design and functionality to enhance user experience throughout the application.

Constructors

PlaceholderManager()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

getErrorPlaceholder() ErrorPlaceholder
Returns the currently set error placeholder or a default one.
getLoadingPlaceholder() LoadingPlaceholder
Returns the currently set loading placeholder or a default one.
setErrorPlaceholderBuilder(ErrorPlaceholder builder()) → void
Sets a custom error placeholder builder.
setLoadingPlaceholderBuilder(LoadingPlaceholder builder()) → void
Sets a custom loading placeholder builder.