single static method
Widget
single({
- required BuildContext context,
- required bool conditionBuilder(
- BuildContext context
- required Widget widgetBuilder(
- BuildContext context
- Widget fallbackBuilder(
- BuildContext context
A function which returns a single Widget
conditionBuilder
is a function which returns a boolean.widgetBuilder
is a function which returns aWidget
, whenconditionBuilder
returnstrue
.fallbackBuilder
is a function which returns aWidget
, whenconditionBuilder
returnsfalse
. IffallbackBuilder
is not provided, aContainer()
will be returned.
Implementation
static Widget single({
required BuildContext context,
required bool Function(BuildContext context) conditionBuilder,
required Widget Function(BuildContext context) widgetBuilder,
Widget Function(BuildContext context)? fallbackBuilder,
}) {
if (conditionBuilder(context) == true) {
return widgetBuilder(context);
} else {
return fallbackBuilder?.call(context) ?? Container();
}
}