FToastStyle.inherit constructor

FToastStyle.inherit({
  1. required FColors colors,
  2. required FTypography typography,
  3. required FStyle style,
  4. required bool touch,
})

Creates a FToastStyle that inherits its properties.

Implementation

factory FToastStyle.inherit({
  required FColors colors,
  required FTypography typography,
  required FStyle style,
  required bool touch,
}) {
  double titleSpacing;
  TextStyle descriptionTextStyle;
  EdgeInsetsGeometry padding;
  if (touch) {
    titleSpacing = 4;
    descriptionTextStyle = typography.xs.copyWith(color: colors.mutedForeground, overflow: TextOverflow.ellipsis);
    padding = const EdgeInsets.symmetric(horizontal: 16, vertical: 14);
  } else {
    titleSpacing = 2;
    descriptionTextStyle = typography.sm.copyWith(color: colors.mutedForeground, overflow: TextOverflow.ellipsis);
    padding = const EdgeInsets.symmetric(horizontal: 16, vertical: 12);
  }

  return FToastStyle(
    decoration: ShapeDecoration(
      shape: RoundedSuperellipseBorder(
        side: BorderSide(color: colors.border, width: style.borderWidth),
        borderRadius: style.borderRadius.md,
      ),
      color: colors.card,
    ),
    iconStyle: IconThemeData(color: colors.foreground, size: typography.md.fontSize),
    titleTextStyle: typography.sm.copyWith(color: colors.foreground, fontWeight: .w500, height: 1),
    titleSpacing: titleSpacing,
    descriptionTextStyle: descriptionTextStyle,
    padding: padding,
  );
}