'sup
A Flutter widget which displays an image, a title, and a subtitle for errors, empty states, or just fancy custom messages.
Getting Started
Follow the installation instructions.
QuickSup
Use QuickSup to quickly show standard errors and empty states, fast and easy.
Ideal for when you want to avoid spending time on your UI messages but want a bit more than a Text widget.
QuickSup.error(
title: 'Nope',
subtitle: 'That didn\'t work, son.',
onRetry: () {},
);
QuickSup.empty(
subtitle: 'No items in this list',
);
SupConfigurator
If you want to customize, one place to do that is SupConfigurator.
This is an InheritedWidget that hosts a default SupConfig wherever you place it in your widget tree. Sup widgets then access the nearest SupConfigurator and render themselves accordingly.
MaterialApp(
title: 'My App',
home: SupConfigurator(
defaults: SupConfig(
alignment: SupAlignment.start,
),
child: myAppContent
),
);
Sup.from (Config/Templates)
If you are going to have different Sup configurations, such as specific errors, specific empty states, hints, etc., this is for you.
Define a SupConfig instance somewhere in your codebase, then pass it to Sup using Sup.from
. That's all. You can pass specific override params too.
Sup.from(MySupConfigs.sendError);
Sup.from(
MySupConfigs.noSearchResults,
subtitle: 'No results found for $query',
);
Sup.from(MySupConfigs.notEnoughEncouragement);
Sup Constructor
Finally, you can also just create a new Sup instance using the constructor.
Sup(
image: Image(...),
title: Text('Hey'),
subtitle: Text('Welcome to the app'),
...
);
Configuration Order
The order in which Sup applies configurations is the following:
- Package defaults (see SupDefaults)
- User defaults (SupConfigurator)
- Sup.from
- Sup parameters