copyWith method
- TextStyle? displayLarge,
- TextStyle? displayMedium,
- TextStyle? displaySmall,
- TextStyle? headlineLarge,
- TextStyle? headlineMedium,
- TextStyle? headlineSmall,
- TextStyle? titleLarge,
- TextStyle? titleMedium,
- TextStyle? titleSmall,
- TextStyle? bodyLarge,
- TextStyle? bodyMedium,
- TextStyle? bodySmall,
- TextStyle? labelLarge,
- TextStyle? labelMedium,
- TextStyle? labelSmall,
Creates a copy of this text theme but with the given fields replaced with the new values.
Consider using Typography.black or Typography.white, which implement the typography styles in the Material Design specification, as a starting point.
link
/// A Widget that sets the ambient theme's title text color for its
/// descendants, while leaving other ambient theme attributes alone.
class TitleColorThemeCopy extends StatelessWidget {
const TitleColorThemeCopy({super.key, required this.titleColor, required this.child});
final Color titleColor;
final Widget child;
@override
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
return Theme(
data: theme.copyWith(
textTheme: theme.textTheme.copyWith(
titleLarge: theme.textTheme.titleLarge!.copyWith(
color: titleColor,
),
),
),
child: child,
);
}
}
See also:
Implementation
TextTheme copyWith({
TextStyle? displayLarge,
TextStyle? displayMedium,
TextStyle? displaySmall,
TextStyle? headlineLarge,
TextStyle? headlineMedium,
TextStyle? headlineSmall,
TextStyle? titleLarge,
TextStyle? titleMedium,
TextStyle? titleSmall,
TextStyle? bodyLarge,
TextStyle? bodyMedium,
TextStyle? bodySmall,
TextStyle? labelLarge,
TextStyle? labelMedium,
TextStyle? labelSmall,
}) {
return TextTheme(
displayLarge: displayLarge ?? this.displayLarge,
displayMedium: displayMedium ?? this.displayMedium,
displaySmall: displaySmall ?? this.displaySmall,
headlineLarge: headlineLarge ?? this.headlineLarge,
headlineMedium: headlineMedium ?? this.headlineMedium,
headlineSmall: headlineSmall ?? this.headlineSmall,
titleLarge: titleLarge ?? this.titleLarge,
titleMedium: titleMedium ?? this.titleMedium,
titleSmall: titleSmall ?? this.titleSmall,
bodyLarge: bodyLarge ?? this.bodyLarge,
bodyMedium: bodyMedium ?? this.bodyMedium,
bodySmall: bodySmall ?? this.bodySmall,
labelLarge: labelLarge ?? this.labelLarge,
labelMedium: labelMedium ?? this.labelMedium,
labelSmall: labelSmall ?? this.labelSmall,
);
}