Skip to content

Text with overflow is clipped from top #98975

@tgucio

Description

@tgucio

Steps to Reproduce

  1. Execute flutter run on the code sample

Expected results: Text rendered correctly whether overflowing or not

Actual results: Text cut above when overflowing:

scr

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    const TextStyle textStyle = TextStyle(
      fontSize: 18.0,
      color: Colors.black,
    );
    const StrutStyle strutStyle = StrutStyle(forceStrutHeight: true, height: 1.0);

    final List<String> texts = <String>[
      'BGBGBGj first line',
      'BGBGBGj second line is a bit longer',
      'BGBGBGj third line is a bit longer and has ellipsis',
      'BGBGBGj fourth line is normal',
      'Lorem ipsum 1',
      'Lorem ipsum 2',
      'Lorem ipsum 3',
      'Lorem ipsum 4',
      'Lorem ipsum 5',
      'Lorem ipsum 6',
      'Lorem ipsum 7',
      'Lorem ipsum 8',
      'Lorem ipsum 9',
      'Lorem ipsum 10',
      'Lorem ipsum 11',
    ];

    final List<Widget> tiles = texts.map((String text) {
      return ListTile(
        title: Text(
          text,
          style: textStyle,
          strutStyle: strutStyle,
          maxLines: 1,
          softWrap: false,
          overflow: TextOverflow.fade,
        ),
      );
    }).toList();

    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: Center(
        child: SizedBox(
          width: 400.0,
          child: Scrollbar(
            child: ListView(children: tiles),
          ),
        ),
      ),
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: typographyText rendering, possibly libtxtc: renderingUI glitches reported at the engine/skia or impeller rendering levelfound in release: 2.10Found to occur in 2.10found in release: 2.11Found to occur in 2.11frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: solvedIssue is closed as solved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions