WaffleTopping.asTitleAndColumnOfIconAndCaptions constructor
WaffleTopping.asTitleAndColumnOfIconAndCaptions({
- required BuildContext context,
- required String titleText,
- required List<
Widget> icons, - required List<
String> contentTexts, - Key? key,
- EdgeInsetsGeometry? margin,
- EdgeInsetsGeometry? padding,
- double? width,
A waffle topping with title and icons and content texts.
Each contentTexts
will be styled with caption, wrapped with Expanded,
and spaced 16 wide with the icon.
titleText
- Will be styled with bodyText2icons
will be paired withcontentText
based on their index. Both must have identical length, otherwise will throw an AssertionError.
Implementation
factory WaffleTopping.asTitleAndColumnOfIconAndCaptions({
required BuildContext context,
required String titleText,
required List<Widget> icons,
required List<String> contentTexts,
Key? key,
EdgeInsetsGeometry? margin,
EdgeInsetsGeometry? padding,
double? width,
}) {
if (icons.length != contentTexts.length) {
throw AssertionError(
'icons and contentTexts should have identical length');
}
Widget title = Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Text(
titleText,
style: Theme.of(context).textTheme.bodyText2,
),
);
Widget content = Column(
children: List<int>.generate(icons.length, (i) => i)
.map(
(i) => Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Row(
children: [
icons[i],
SizedBox(width: 16),
Expanded(
child: Text(
contentTexts[i],
style: Theme.of(context).textTheme.caption,
),
)
],
),
),
)
.toList(),
);
return WaffleTopping(
key: key,
title: title,
content: content,
margin: margin,
padding: padding,
width: width,
);
}