getThemeData method
ThemeData
getThemeData({
- required BuildContext context,
- Brightness? brightness,
- bool needTextTheme = true,
- bool needColorScheme = true,
Returns a ThemeData instance based on the current brightness and configuration.
Implementation
ThemeData getThemeData(
{required BuildContext context, Brightness? brightness, bool needTextTheme = true, bool needColorScheme = true}) {
Brightness? br = brightness ?? _brightness;
if (br == null) {
try {
br = Theme.of(context).brightness;
} catch (e) {
br = Brightness.light;
}
}
TencentCloudChatThemeColors colorTheme = (br == Brightness.light ? _themeModel.lightTheme : _themeModel.darkTheme);
return ThemeData(
useMaterial3: true,
textTheme: needTextTheme
? TextTheme(
bodyLarge:
TextStyle(color: colorTheme.primaryTextColor, fontSize: _themeModel.textStyle.standardLargeText),
bodyMedium: TextStyle(color: colorTheme.primaryTextColor, fontSize: _themeModel.textStyle.standardText),
bodySmall:
TextStyle(color: colorTheme.primaryTextColor, fontSize: _themeModel.textStyle.standardSmallText),
)
: null,
colorScheme: needColorScheme ? colorTheme.toColorScheme(br) : null,
);
}