🧩 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