HatangChatTheme class
Colours and shapes of the chat UI, as a ThemeExtension so hosts can
register it on their ThemeData or pass it to HatangChat.configure.
- Inheritance
-
- Object
- ThemeExtension<
HatangChatTheme> - HatangChatTheme
Constructors
- HatangChatTheme({required Brightness brightness, required HatangPalette palette, required Color accent, required Color onAccent, String? fontFamily, double bubbleRadius = HatangRadius.lg, Color? mineBubble, Color? onMineBubble, Color? theirBubble, Color? onTheirBubble})
-
Creates a theme.
const
- HatangChatTheme.dark({Color accent = const Color(0xFF38BDF8), String? fontFamily})
-
Dark theme with
accent.factory - HatangChatTheme.fromSite(SiteConfig? config, Brightness brightness, {String? fontFamily})
-
Theme from the site's accent colour for
brightness.factory - HatangChatTheme.light({Color accent = const Color(0xFF0EA5E9), String? fontFamily})
-
Light theme with
accent(default: Hatang sky).factory
Properties
- accent → Color
-
Accent (site colour): send button, own bubbles, links.
final
- accentText → Color
-
The accent as a text colour on the chat's backgrounds (quick replies,
outlined buttons, links, prices): the site colour itself when it reads
at WCAG AA (4.5:1) on the page, bubble and card backgrounds, otherwise
the nearest darker (light theme) or lighter (dark theme) shade that does.
no setter
- brightness → Brightness
-
Light or dark.
final
- bubbleRadius → double
-
Bubble corner radius.
final
- fontFamily → String?
-
Font family for every text (null = the host's).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- mine → Color
-
Resolved own bubble background.
no setter
- mineBubble → Color?
-
Own bubble background (default: accent).
final
- onAccent → Color
-
Text on accent, chosen by luminance.
final
- onMine → Color
-
Resolved own bubble text.
no setter
- onMineBubble → Color?
-
Own bubble text (default: onAccent).
final
- onTheirBubble → Color?
-
Their bubble text (default: fg).
final
- onTheirs → Color
-
Resolved their bubble text.
no setter
- palette → HatangPalette
-
Base colours.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- theirBubble → Color?
-
Their bubble background (default: raised surface).
final
- theirs → Color
-
Resolved their bubble background.
no setter
- type → Object
-
The extension's type.
no setterinherited
Methods
-
Label style for a button's
textStyle: Material buttons do not inherit the surrounding text style, so without the host'slabelLargethe label would fall back to the platform font instead of the app's. -
copyWith(
{Brightness? brightness, HatangPalette? palette, Color? accent, Color? onAccent, String? fontFamily, double? bubbleRadius, Color? mineBubble, Color? onMineBubble, Color? theirBubble, Color? onTheirBubble}) → HatangChatTheme -
Creates a copy of this theme extension with the given fields
replaced by the non-null parameter values.
override
-
lerp(
covariant ThemeExtension< HatangChatTheme> ? other, double t) → HatangChatTheme -
Linearly interpolate with another ThemeExtension object.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
text(
TextStyle base, {Color? color}) → TextStyle - Base text style with fontFamily.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
contrastRatio(
Color a, Color b) → double - WCAG 2 contrast ratio between two opaque colours (1 to 21).
-
of(
BuildContext context) → HatangChatTheme -
The theme to use inside
context: the registered extension, else one derived from the ambient brightness. -
onAccentFor(
Color c) → Color -
Near-black or white, whichever has the higher WCAG contrast on
c(a mid blue such as#0ea5e9gets dark text: white would be 2.8:1). -
parseHexColor(
String? hex) → Color? -
Parses
#rgb,#rrggbbor#rrggbbaa. -
readableOn(
Color c, List< Color> backgrounds, {double ratio = 4.5}) → Color -
cmoved towards black or white in small steps until it reachesratioagainst every colour inbackgrounds(opaque: blend a translucent tint over its base withColor.alphaBlendfirst).