list static method
List<Widget>
list({
- required BuildContext context,
- required bool conditionBuilder(
- BuildContext context
- required List<
Widget> widgetBuilder(- BuildContext context
- List<
Widget> fallbackBuilder(- BuildContext context
A function which returns a List<Widget>
conditionBuilder
is the function which returns a boolean.widgetBuilder
is a function which returns aList<Widget>
, whenconditionBuilder
returnstrue
.fallbackBuilder
is a function which returns aList<Widget>
, whenconditionBuilder
returnsfalse
. IffallbackBuilder
is not provided, an empty list will be returned.
Implementation
static List<Widget> list({
required BuildContext context,
required bool Function(BuildContext context) conditionBuilder,
required List<Widget> Function(BuildContext context) widgetBuilder,
List<Widget> Function(BuildContext context)? fallbackBuilder,
}) {
if (conditionBuilder(context) == true) {
return widgetBuilder(context);
} else {
return fallbackBuilder?.call(context) ?? [];
}
}