Skip to content

When using letterSpacing in rich text while a width is specified, characters disappear at line breaks #184818

Closed

Description

@hatano0x06

Steps to reproduce

  1. run sample code

Expected results

All characters are displayed

Actual results

The character that should appear at the end of the first line of an item with letterSpacing (character 89 in the screenshot) is missing.
Additionally, if maxlines is not specified, the text extends beyond the specified range.

Code sample

Code sample
import 'package:flutter/material.dart';

void main(List<String> args) {
  runApp(MaterialApp(home: SamplePage()));
}

class SamplePage extends StatefulWidget {

  SamplePage(): super();

  @override
  SamplePageState createState() => SamplePageState();
}


class SamplePageState extends State<SamplePage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('sample'),
      ),
      body : body(),
      // body: 
    );
  }

  Widget body(){

    TextSpan letterSpacingSpan = TextSpan(
      children: [
        TextSpan( text: "12345", style: TextStyle(letterSpacing: 30, color: Colors.black), ),        
        TextSpan( text: "67890" + "1234567890" * 20, style: TextStyle(color: Colors.black), ),
      ]);

    TextSpan normalSpan = TextSpan(
      children: [
        TextSpan( text: "12345", style: TextStyle(color: Colors.black), ),        
        TextSpan( text: "67890" + "1234567890" * 20, style: TextStyle(color: Colors.black), ),
      ]);

    return Column(children: [
      SizedBox(height: 20,),
      Text("letterSpacing + maxlines"),
      Container(
        width : 300,
        color : Colors.red.withAlpha(100),
        child : RichText(text: letterSpacingSpan, maxLines: 3,),
      ),

      SizedBox(height:20),
      Divider(),
      SizedBox(height:20),

      Text("letterSpacing"),
      Container(
        width : 300,
        color : Colors.red.withAlpha(100),
        child : RichText(text: letterSpacingSpan, ),
      ),

      SizedBox(height:20),
      Divider(),
      SizedBox(height:20),

      Text("maxlines"),
      Container(
        width : 300,
        color : Colors.red.withAlpha(100),
        child : RichText(text: normalSpan, maxLines: 3,),
      ),

      SizedBox(height:20),
      Divider(),
      SizedBox(height:20),

      Text("nothing"),
      Container(
        width : 300,
        color : Colors.red.withAlpha(100),
        child : RichText(text: normalSpan,),
      ),

    ],);

  }
}


Screenshots or Video

Screenshots / Video demonstration Image

Logs

Logs
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
√ Built build\app\outputs\flutter-apk\app-debug.apk
D/FlutterJNI( 4588): Beginning load of flutter...
D/FlutterJNI( 4588): flutter (null) was loaded normally!
I/flutter ( 4588): [IMPORTANT:flutter/shell/platform/android/android_context_gl_impeller.cc(104)] Using the Impeller rendering backend (OpenGLES).
D/FlutterArchivePlugin( 4588): onAttachedToEngine - IN
D/FlutterArchivePlugin( 4588): doOnAttachedToEngine - IN
D/FlutterArchivePlugin( 4588): doOnAttachedToEngine - OUT
D/FlutterArchivePlugin( 4588): onAttachedToEngine - OUT
I/FlutterInappPurchase( 4588): Initializing Android IAP plugin
W/ga.storyplotter( 4588): Verification of void io.flutter.plugins.webviewflutter.AndroidWebkitLibraryPigeonProxyApiBaseCodec.writeValue(java.io.ByteArrayOutputStream, java.lang.Object) took 114.981ms (7705.61 bytecodes/s) (33344B approximate peak alloc)
W/ga.storyplotter( 4588): Accessing hidden method Landroid/view/accessibility/AccessibilityNodeInfo;->getSourceNodeId()J (unsupported,test-api, reflection, allowed)
W/ga.storyplotter( 4588): Accessing hidden method Landroid/view/accessibility/AccessibilityRecord;->getSourceNodeId()J (unsupported, reflection, allowed)
W/ga.storyplotter( 4588): Accessing hidden field Landroid/view/accessibility/AccessibilityNodeInfo;->mChildNodeIds:Landroid/util/LongArray; (unsupported, reflection, allowed)
W/ga.storyplotter( 4588): Accessing hidden method Landroid/util/LongArray;->get(I)J (unsupported, reflection, allowed)
D/FlutterRenderer( 4588): Width is zero. 0,0
I/FA      ( 4588): Tag Manager is not found and thus will not be used
D/FirebaseSessions( 4588): App foregrounded on com.hhatamanga.storyplotter
D/FirebaseSessions( 4588): Session 9c4f2f9f45f64788a93a20831b5f2e39 has not backgrounded yet

Flutter Doctor output

Doctor output
flutter doctor -v
[√] Flutter (Channel stable, 3.41.6, on Microsoft Windows [Version 10.0.26200.8117], locale ja-JP) [483ms]
    • Flutter version 3.41.6 on channel stable at C:\Users\81708\Desktop\develop\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision db50e20168 (2 weeks ago), 2026-03-25 16:21:00 -0700
    • Engine revision 425cfb54d0
    • Dart version 3.11.4
    • DevTools version 2.54.2
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration

[√] Windows Version (11 Pro 64-bit, 25H2, 2009) [1,741ms]

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [9.4s]
    • Android SDK at C:\Users\81708\AppData\Local\Android\sdk
    • Emulator version 31.3.14.0 (build_id 9322596) (CL:N/A)
    • Platform android-36, build-tools 35.0.0
    • Java binary at: C:\Program Files\Android\Android Studio3\jbr\bin\java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)
    • All Android licenses accepted.

[√] Chrome - develop for the web [233ms]
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.14.8) [232ms]
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.14.36301.6
    • Windows 10 SDK version 10.0.26100.0

[√] Connected device (4 available) [597ms]
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.26200.8117]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 146.0.7680.178
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 146.0.3856.109

[√] Network resources [506ms]
    • All expected network resources are available.

• No issues found!

Activity

  1. hatano0x06 commented on Apr 9, 2026

    @hatano0x06
    Author

    I believe this is likely related to the issue below, but since the symptoms are different, I have submitted it as a separate issue.
    #184815

  2. added
    in triagePresently being triaged by the triage team
    r: duplicateIssue is closed as a duplicate of an existing issue
    and removed
    in triagePresently being triaged by the triage team
    on Apr 9, 2026
  3. mbcorona commented on Apr 9, 2026

    @mbcorona
    Member

    Closing this as a duplicate of #184815, since both issues track the exact same underlying text layout calculation bug when letterSpacing interacts with width or line constraints. We will track the engine fix over on that thread!

  4. github-actions commented on Apr 23, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: duplicateIssue is closed as a duplicate of an existing issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions