modify method
Build a text paragraph with some modification.
Implementation
@override
Widget modify(BuildContext context, Widget child) {
final ctheme = BoustroComponentConfig.of(context);
final theme = Theme.of(context);
final TextStyle? style;
switch (level) {
case 1:
style = ctheme.headingStyle1 ?? theme.textTheme.headline4;
break;
case 2:
style = ctheme.headingStyle2 ?? theme.textTheme.headline5;
break;
case 3:
style = ctheme.headingStyle3 ?? theme.textTheme.headline6;
break;
case 4:
style = ctheme.headingStyle4 ?? theme.textTheme.subtitle1;
break;
case 5:
style = ctheme.headingStyle5 ?? theme.textTheme.subtitle1;
break;
case 6:
style = ctheme.headingStyle6 ?? theme.textTheme.subtitle1;
break;
default:
throw Exception('Invalid heading level "$level".');
}
return Theme(
data: theme.copyWith(
textTheme: theme.textTheme.copyWith(
subtitle1: style,
),
),
child: child,
);
}