state_illustrator π¨
A Flutter helper widget to display loading, empty, error, and success screen states with customizable illustrations and smooth transitions.
π¬ GIF Previews
| Loading | Empty | Error |
|---|---|---|
![]() |
![]() |
![]() |
π Features
- π¦ Builtβin support for loading, empty, error, and success states
- π¨ Supports Lottie (
.json), SVG (.svg), and PNG (.png) assets - π Smooth fade transition between states
- π§ Easily customizable themes, titles, subtitles, and retry button
- π§© Use custom widgets in place of illustrations
π Screenshots
(Add screenshots or GIFs showing each state)
π¦ Installation
Add the dependency to your pubspec.yaml:
dependencies:
state_illustrator: ^1.0.0
Then run:
flutter pub get
π§ How It Works
StateIllustrator observes a view state and shows the appropriate UI:
| ViewState | Displays |
|---|---|
initial |
Empty placeholder |
loading |
Loading animation or asset |
empty |
Empty illustration |
error |
Error illustration + retry |
success |
Your content (child) |
π Usage
Basic Example
StateIllustrator(
state: _state,
onRetry: () => _fetchData(),
child: Center(
child: Text(
'Data Loaded Successfully!',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
),
)
π¨ Customization
You can override all visuals using GlobalIllustratorConfig:
final globalConfig = GlobalIllustratorConfig(
loadingConfig: IllustrationConfig(
assetPath: 'assets/animations/loading.json',
assetType: AssetType.lottie,
title: 'Loading...',
subtitle: 'Fetching data, please wait...',
),
emptyConfig: IllustrationConfig(
assetPath: 'assets/images/empty.svg',
assetType: AssetType.svg,
title: 'No Items',
subtitle: 'Try adding some items!',
),
errorConfig: IllustrationConfig(
assetPath: 'assets/images/error.png',
assetType: AssetType.png,
title: 'Something went wrong',
subtitle: 'Please try again later.',
buttonStyle: ElevatedButton.styleFrom(primary: Colors.red),
),
theme: IllustratorTheme(
backgroundColor: Colors.white,
titleStyle: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
subtitleStyle: TextStyle(fontSize: 16),
),
);
Then apply it in your widget:
StateIllustrator(
state: _state,
config: globalConfig,
onRetry: _fetchData,
child: YourContentWidget(),
)
π§© Custom Widgets Support
If you want complete control, provide customWidget:
IllustrationConfig(
customWidget: YourCustomWidget(),
)
This overrides any asset.
π Defaults
The package includes default assets and texts:
| State | Asset Path | Title | Subtitle |
|---|---|---|---|
| Loading | assets/default/loading.json |
Loading... | Please wait a moment. |
| Empty | assets/default/empty.svg |
Nothing here | No data available. |
| Error | assets/default/error.png |
Oops! | Something went wrong. |
π¦ Contributing
Contributions are welcome! To contribute:
- π΄ Fork this repo
- π§© Create your feature branch (git checkout -b feature/AmazingFeature)
- π Commit your changes (git commit -m "Add AmazingFeature")
- π Push (git push origin feature/AmazingFeature)
- π Open a Pull Request
π License
This project is licensed under the MIT License. Β© ASHISH1317


