Show API docs
Conditionally render its builder or an optional fallback component based on the when evaluation.
final loggedIn = Signal(false);
@override
Widget build(BuildContext context) {
return Show(
when: loggedIn,
builder: (context) => const Text('Logged In'),
fallback: (context) => const Text('Logged out'),
);
}
Constructor
Show({
bool Function()? when,
WidgetBuilder builder,
WidgetBuilder? fallback,
});
A boolean Signal used to determine which builder needs to be used.
When the Signal's value is true, renders the builder, otherwise the fallback (if provided, or an empty view).
The Show
widget takes a functions that returns a bool
.
You can easily convert any type to bool
, for example:
final count = Signal(0);
@override
Widget build(BuildContext context) {
return Show(
when: () => count() > 5,
builder: (context) => const Text('Count is greater than 5'),
fallback: (context) => const Text('Count is lower than 6'),
);
}