of static method
Returns the StreamTheme from the closest Theme ancestor.
If no StreamTheme is found in the widget tree, a default theme is returned based on the current Theme's brightness (light or dark).
{@tool snippet}
Access the theme in a widget:
@override
Widget build(BuildContext context) {
final theme = StreamTheme.of(context);
return Container(
color: theme.colorScheme.backgroundPrimary,
padding: EdgeInsets.all(theme.spacing.md),
child: Text('Hello', style: theme.textTheme.bodyDefault),
);
}
{@end-tool}
Implementation
static StreamTheme of(BuildContext context) {
final theme = Theme.of(context);
final streamTheme = theme.extension<StreamTheme>();
if (streamTheme != null) return streamTheme;
return StreamTheme(brightness: theme.brightness);
}