🧩 View State Widget

A simple yet powerful Flutter widget for handling loading, content, error, and network error UI states — with just one line of code.


✨ Preview

Loading Error
Network Content


🚀 Features

✅ Show different UI states effortlessly
✅ Built-in retry support
✅ Easily customizable widgets
✅ Fully theme-aware
✅ Flutter + Dart package ready for production


🛠 Usage

StateView(
  state: ViewState.loading, // or content, error, networkError
  content: Text("🎉 Content Loaded!"),
  onRetry: _fetchData, // optional retry callback
);

🎯 ViewState Options

ViewState.loading

ViewState.content

ViewState.error

ViewState.networkError

🎨 Customization You can override the default UI for each state:

StateView(
  state: ViewState.error,
  content: YourContentWidget(),
  errorWidget: Column(
    children: [
      Text("Something went wrong"),
      ElevatedButton(onPressed: _retry, child: Text("Retry")),
    ],
  ),
)

📦 Installation Add this to your pubspec.yaml:

dependencies:
  view_state_widget: ^1.0.0

Then run:

flutter pub get

Libraries

view_state_widget