buildAction method

  1. @override
Widget buildAction(
  1. BuildContext context
)
override

Builds the action.

Implementation

@override
Widget buildAction(BuildContext context) {
  final Color estimatedColor =
      ThemeData.estimateBrightnessForColor(color!) == Brightness.light
          ? Colors.black
          : Colors.white;

  final List<Widget> widgets = [];

  if (icon != null) {
    widgets.add(
      Flexible(
        child: Icon(
          icon,
          color: foregroundColor ?? estimatedColor,
        ),
      ),
    );
  }

  if (iconWidget != null) {
    widgets.add(
      Flexible(child: iconWidget!),
    );
  }

  if (caption != null) {
    widgets.add(
      Flexible(
        child: Text(
          caption!,
          overflow: TextOverflow.ellipsis,
          style: Theme.of(context)
              .primaryTextTheme
              .caption!
              .copyWith(color: foregroundColor ?? estimatedColor),
        ),
      ),
    );
  }

  return Center(
    child: Column(
      mainAxisSize: MainAxisSize.min,
      children: widgets,
    ),
  );
}