-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
The documentation says we need to enable backwardsCompatibility to use toolbarTextStyle and titleTextStyle, but I can only use them when I disable it.
I've made a repo with a piece of code to try the functionality: https://github.com/Charly6596/Title-text-style-issue
The fact that the documentation says that toolbarTextStyle is obsolete also confuses me.
| /// Overrides the default value for the obsolete [AppBar.toolbarTextStyle] |
By reading #71184 (comment) I assume that the documentation should be fixed and the behaviour is correct.
Also, the AppBar documentation isn't updated regarding to the backwardsCompatibility flag.
The current behaviour can be observed in the implementation:
flutter/packages/flutter/lib/src/material/app_bar.dart
Lines 836 to 850 in 7d707b0
| TextStyle? toolbarTextStyle = backwardsCompatibility | |
| ? widget.textTheme?.bodyText2 | |
| ?? appBarTheme.textTheme?.bodyText2 | |
| ?? theme.primaryTextTheme.bodyText2 | |
| : widget.toolbarTextStyle | |
| ?? appBarTheme.toolbarTextStyle | |
| ?? theme.textTheme.bodyText2?.copyWith(color: foregroundColor); | |
| TextStyle? titleTextStyle = backwardsCompatibility | |
| ? widget.textTheme?.headline6 | |
| ?? appBarTheme.textTheme?.headline6 | |
| ?? theme.primaryTextTheme.headline6 | |
| : widget.titleTextStyle | |
| ?? appBarTheme.titleTextStyle | |
| ?? theme.textTheme.headline6?.copyWith(color: foregroundColor); |
The fact that #81675 (comment) mentions that the value should be true to use
titleTextStyle confused me, commenting it just so others can be redirected here if they had the same problem as the OP
