AlertStyle class

How alerts are drawn — quotes that open with a marker such as [!NOTE]:

> [!TIP]
> Pin the version in production.

Every field is optional. The fields at the top level apply to every alert type, and note, tip, important, warning and caution override them for one type, field by field:

GptMarkdown(
  text,
  styleSheet: const GptMarkdownStyleSheet(
    alert: AlertStyle(
      barWidth: 4,
      backgroundColor: Color(0x0A000000),
      warning: AlertStyle(title: 'Heads up', icon: Icons.bolt),
    ),
  ),
)

Anything still unset resolves per type: an accent colour for the light or dark scheme, an icon, and an English title. For structure rather than looks, use GptMarkdown.alertBuilder.

Annotations

Constructors

AlertStyle({Color? color, Color? backgroundColor, IconData? icon, double? iconSize, bool? showIcon, String? title, TextStyle? titleStyle, double? titleGap, TextStyle? textStyle, double? barWidth, Radius? borderRadius, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, AlertStyle? note, AlertStyle? tip, AlertStyle? important, AlertStyle? warning, AlertStyle? caution})
Creates an alert style. Null fields fall back to the per-type override, then to this style, then to the theme, then to the default.
const

Properties

backgroundColor → Color?
Fill behind the alert. Defaults to a faint tint of color — 8% opacity, 12% on a dark ColorScheme — which blends with whatever surface the alert sits on. Colors.transparent turns it off.
final
barWidth → double?
Thickness of the bar down the side. Defaults to 3.
final
borderRadius → Radius?
Rounding of the alert's corners. The bar is clipped to it as well. Defaults to 6; Radius.zero gives square corners.
final
caution → AlertStyle?
Overrides for [!CAUTION].
final
color → Color?
Accent colour of the bar, the icon and the title. Defaults to a colour per type, adjusted for a dark ColorScheme.
final
hashCode → int
The hash code for this object.
no setteroverride
icon → IconData?
Icon before the title. Defaults to one per type.
final
iconSize → double?
Size of the icon. Defaults to 1.15 × the title's font size.
final
important → AlertStyle?
Overrides for [!IMPORTANT].
final
margin → EdgeInsetsGeometry?
Space around the whole alert. Defaults to vertical: 4.
final
note → AlertStyle?
Overrides for [!NOTE].
final
padding → EdgeInsetsGeometry?
Space between the edges of the alert and its content, the bar included on the start side. Defaults to 12 at the sides and 8 at the top and bottom.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
showIcon → bool?
Whether the icon is drawn. Defaults to true.
final
textStyle → TextStyle?
Applied on top of the surrounding text style for the body. Defaults to no change.
final
tip → AlertStyle?
Overrides for [!TIP].
final
title → String?
Text of the title — "Note", "Tip", "Important", "Warning" or "Caution" by default. An empty string hides the title row.
final
titleGap → double?
Space between the title row and the body. Defaults to 4.
final
titleStyle → TextStyle?
Applied on top of the title's default: the surrounding text style in the accent color, semi-bold.
final
warning → AlertStyle?
Overrides for [!WARNING].
final

Methods

copyWith({Color? color, Color? backgroundColor, IconData? icon, double? iconSize, bool? showIcon, String? title, TextStyle? titleStyle, double? titleGap, TextStyle? textStyle, double? barWidth, Radius? borderRadius, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, AlertStyle? note, AlertStyle? tip, AlertStyle? important, AlertStyle? warning, AlertStyle? caution}) → AlertStyle
A copy with the given fields replaced.
merge(AlertStyle? other) → AlertStyle
This style, with any unset field taken from other, field by field — the per-type overrides included.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
overrideFor(MarkdownAlertType type) → AlertStyle?
The override for type, or null.
resolve(MarkdownAlertType type, ColorScheme scheme) → AlertStyle
The style of one type with every remaining default filled in.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
override

Static Methods

lerp(AlertStyle? a, AlertStyle? b, double t) → AlertStyle?
Linearly interpolates between two alert styles.