Text Inside widgetspan does not respect TextScaler.linear
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.1k
- PR merge metrics
- PR metrics pending
Description
### Steps to reproduce
Adding a `TextSpan` > `WidgetSpan` > `MaybeOtherWidget` > `Text` causes the `Text` widget to be scaled twice with the text scaler. This obviously becomes very problematic for large fonts.
### Expected results
Text should scale only once
### Actual results
Text scales twice
### Code sample
Code sample
```dart
final size = 14;
final child = Text.rich(
TextSpan(
children: [
TextSpan(text: "A", style: TextStyle(fontSize: size)),
WidgetSpan(
child: Text(
"A",
style: TextStyle(fontSize: size),
),
),
],
)
);
return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaler: TextScaler.linear(2)),
child: child,
);
```
### Screenshots or Video
Screenshots / Video demonstration
The smaller `4` in the first image scales to be larger than the other numbers as the scaler increases, despite having a smaller font size.
### Logs
Logs
```console
[Paste your logs here]
```
### Flutter Doctor output
Doctor output
```console
➜ ~ flutter doctor -v
[✓] Flutter (Channel stable, 3.29.2, on macOS 15.3.1 24D70 darwin-arm64, locale en-GB) [2.0s]
• Flutter version 3.29.2 on channel stable at
/Users/alexandrudochioiu/.asdf/installs/flutter/3.29.2-stable
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c236373904 (2 weeks ago), 2025-03-13 16:17:06 -0400
• Engine revision 18b71d647a
• Dart version 3.7.2
• DevTools version 2.42.3
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [2.6s]
• Android SDK at /Users/alexandrudochioiu/Library/Android/sdk
• Platform android-35, build-tools 35.0.1
• ANDROID_HOME = /Users/alexandrudochioiu/Library/Android/sdk
• Java binary at:
/Users/alexandrudochioiu/Library/Java/JavaVirtualMachines/corretto-17.0.11/Contents/Home/bin/java
This JDK is specified in your Flutter configuration.
To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment Corretto-17.0.11.9.1 (build 17.0.11+9-LTS)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [2.6s]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [38ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.2) [37ms]
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
[✓] IntelliJ IDEA Community Edition (version 2022.3.3) [36ms]
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.98.1) [12ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.106.0
[✓] Connected device (5 available) [12.5s]
[REDACTED]
[✓] Network resources [440ms]
• All expected network resources are available.
• No issues found!
```
Contributor guide
Assessment
This issue has not been assessed yet.