list<T> static method
List<Widget>
list<T>({
- required BuildContext context,
- required T valueBuilder(
- BuildContext context
- required Map<
T, List< caseBuilders,Widget> Function(BuildContext context)> - List<
Widget> fallbackBuilder(- BuildContext context
A function which returns a List<Widget>
valueBuilder
is a function which returns a value.caseBuilders
is aMap
of value toList<Widget>
builders, when one of the keys matches the value returns byvalueBuilder
, the correspondingList<Widget>
builder will be used.fallbackBuilder
is a function which returns aList<Widget>
, it is used when none of the keys incaseBuilders
matches the value returns byvalueBuilder
. IffallbackBuilder
is not provided, an empty list will be returned.
Implementation
static List<Widget> list<T>({
required BuildContext context,
required T Function(BuildContext context) valueBuilder,
required Map<T, List<Widget> Function(BuildContext context)> caseBuilders,
List<Widget> Function(BuildContext context)? fallbackBuilder,
}) {
final T value = valueBuilder(context);
if (caseBuilders[value] != null) {
return caseBuilders[value]!(context);
} else {
return fallbackBuilder?.call(context) ?? [];
}
}