build method
Builds the layout for the content item. This transforms the content into a Flutter Widget.
Implementation
@override
Widget build(BuildContext context, Card content) {
final theme = Theme.of(context);
final innerChild = Text(content.title ?? 'Untitled');
final onPressedAction =
content.action != null ? () => content.action!.execute(context) : null;
final button = switch (buttonType) {
ButtonType.filled => ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: theme.colorScheme.primary,
foregroundColor: theme.colorScheme.onPrimary,
),
onPressed: onPressedAction,
child: innerChild,
),
ButtonType.outlined => OutlinedButton(
onPressed: onPressedAction,
child: innerChild,
),
ButtonType.text => TextButton(
onPressed: onPressedAction,
child: innerChild,
),
};
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: isStretched
? SizedBox(
width: double.maxFinite,
child: button,
)
: button,
);
}