ChartTheme.fromMaterialTheme constructor

ChartTheme.fromMaterialTheme(
  1. ThemeData theme
)

Create theme from Material Theme.

Automatically infers the appropriate chart theme (light or dark) based on the brightness of the provided Material theme.

Parameters:

  • theme - The Material theme to infer from

Returns ChartTheme.dark() if theme brightness is dark, ChartTheme.light() otherwise.

Example

final chartTheme = ChartTheme.fromMaterialTheme(Theme.of(context));

Implementation

factory ChartTheme.fromMaterialTheme(ThemeData theme) {
  final isDark = theme.brightness == Brightness.dark;
  return isDark ? ChartTheme.dark() : ChartTheme.light();
}