textOnColor static method

Widget textOnColor(
  1. BuildContext context, {
  2. required String text,
  3. bool expanded = false,
  4. TextStyle? style,
  5. Color? backgroundColor,
  6. TextAlign? textAlign,
  7. double horizontalGap = 10,
  8. double verticalGap = 10,
})

Implementation

static Widget textOnColor(BuildContext context, {required String text, bool expanded = false, TextStyle? style, Color? backgroundColor, TextAlign? textAlign, double horizontalGap = 10, double verticalGap = 10})
{
  Widget c = Container(
    decoration: BoxDecoration(
        color: backgroundColor ?? Colors.grey.shade200,
        borderRadius: BorderRadius.circular(6)
    ),
    padding: EdgeInsets.symmetric(horizontal: horizontalGap, vertical: verticalGap),
    child: Text(
      text,
      style: style ?? Theme.of(context).textTheme.titleMedium!.copyWith(color: Colors.black87),
      textAlign: textAlign,
    ),
  );

  if (expanded) {
    return Row(children: [c.expanded()]);
  }
  else {
    return c;
  }
}