Skip to content

TextOverflow.fade results in unexpected fade direction #13631

Description

@mehmetf
import 'package:flutter/material.dart';

void main() {
  runApp(new FadeDemo());
}

class FadeDemo extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    var themeData = new ThemeData();
    return new MaterialApp(
        theme: themeData,
        home: new Scaffold(
          appBar: new AppBar(title: const Text('Fade Effect')),
          body: new Center(
            child: new Container(
              color: Colors.grey[300],
              width: 250.0,
              child: new Text(
                'This is a short text.',
                style: themeData.textTheme.title.copyWith(fontSize: 48.0),
                maxLines: 1,
                overflow: TextOverflow.fade,
              ),
            ),
          ),
        ));
  }
}

results in:

image

I was expecting it to fade out horizontally. If I set overflow to ellipsis, it works as expected and puts the ellipsis at the end.

If I turn off softwrap, fade works as expected. That's counterintuitive given that I would have expected softwrap to have no effect because of maxLines: 1.

Activity

  1. jason-simmons commented on Dec 20, 2017

    @jason-simmons
    Member

    See https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/rendering/paragraph.dart#L178

    If softWrap is on, then the width constraint is given to the text renderer so it knows where to apply wrapping. The renderer then reports that the text filled the maximum width but would have wrapped to the next line. So the fade effect is then painted at the bottom of the text to signify that the text overflowed its height constraint.

  2. mehmetf commented on Dec 22, 2017

    @mehmetf
    ContributorAuthor

    Perhaps then the problem is our understanding of the parameters for Text.

    When we don't want text to wrap (but instead clip) we use maxLines parameter, which is a standard Android paradigm. It seems like we should be using softWrap: false?

  3. Hixie commented on Jan 2, 2018

    @Hixie
    Contributor

    If you don't want text to wrap (except at explicit line breaks), then setting softWrap: false on Text will achieve the effect you want. "maxLines" is more about what to do with the lines once they are wrapped.

  4. mehmetf commented on Jan 6, 2018

    @mehmetf
    ContributorAuthor

    Thanks!

  5. Hixie commented on Jan 7, 2018

    @Hixie
    Contributor

    I'm going to re-open this bug to make sure the documentation explains this, including screenshots.

  6. added this to the milestone on Jan 7, 2018
  7. Pavel-Sulimau commented on Aug 18, 2019

    @Pavel-Sulimau
  8. jccd1996 commented on Apr 20, 2020

    @jccd1996
  9. lock commented on May 5, 2020

    @lock
    lockbot
  10. locked and limited conversation to collaborators on May 5, 2020
  11. nt4f04uNd commented on Jun 2, 2023

    @nt4f04uNd
    Member

    I'm going to re-open this bug to make sure the documentation explains this, including screenshots.

    Seems like this wasn't properly re-opened :-)

  12. unlocked this conversation on Jun 2, 2023
  13. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Jul 18, 2023
  14. added
    P2Important issues not at the top of the work list
    on Jul 18, 2023
  15. added a commit that references this issue on Dec 18, 2023
    b893884
  16. added a commit that references this issue on Dec 28, 2023
    2ba1e97
  17. github-actions commented on Jan 1, 2024

    @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.

  18. locked as resolved and limited conversation to collaborators on Jan 1, 2024
  19. added
    r: fixedIssue is closed as already fixed in a newer version
    on Feb 1, 2024
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

    P2Important issues not at the top of the work listd: api docsIssues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions