Skip to content

Broken text field with set hint and min and max lines #153183

Description

@simon-the-shark

Steps to reproduce

  1. use new stable Flutter (3.24.0) - I believe this is a new issue
  2. Just placeTextField with long hint, minLines = 1, maxLines=4 (example values)
  3. type in a short text

Expected results

I except the field to have as many lines as the short text needs, not the hint (when it's not visible)

Actual results

when we have long hint and it needs more lines, even though we typed some short text and the hint is not visible, the text fields still have as many lines as the hint needs

Code sample

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

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

class _MyHomePageState extends State<MyHomePage> {
  bool useHint = true;

  void toggleHint() {
    setState(() {
      useHint = !useHint;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              width: 200,
              decoration: BoxDecoration(
                  border: Border.all(color: Colors.blue, width: 4.0)),
              child: TextField(
                minLines: 1, // this here causes problem
                maxLines: 4, // this here causes problem
                decoration: InputDecoration(
                    hintText: useHint // with hint there is a problem
                        ? "veeeery loooooooooooooooooong hiiiintttttttttt"
                        : null),
              ),
            ),
            Switch(value: useHint, onChanged: (_) => toggleHint())
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Nagranie.z.ekranu.2024-08-9.o.19.23.56.mov

Logs

Logs

https://pastebin.com/EuCj4Cvk

Flutter Doctor output

Doctor output
shark@sharkbook hint_issue % fvm flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel stable, 3.24.0, on macOS 14.4.1 23E224 darwin-arm64, locale pl-PL)
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/2.17.6/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/shark/fvm/versions/stable. Consider adding /Users/shark/fvm/versions/stable/bin to the front of your path.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.1.4)
[✓] VS Code (version 1.92.1)
[✓] Connected device (4 available)
[✓] Network resources```

</details>

Activity

  1. added
    in triagePresently being triaged by the triage team
    on Aug 12, 2024
  2. huycozy commented on Aug 12, 2024

    @huycozy
    Member

    Thanks for your report and submitting a PR, @simon-the-shark!

    I can reproduce this issue as well. I also see there is an issue #52008 that looks similar to this. Can you take a look and confirm if it's a similar underlying case?

  3. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 12, 2024
  4. simon-the-shark commented on Aug 12, 2024

    @simon-the-shark
    Author

    Yeah. This issue seems to be very similar. Probably the same root cause, but the config that brings this out is a bit different. But yeah, probably variation of the same root issue.

  5. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 12, 2024
  6. huycozy commented on Aug 13, 2024

    @huycozy
    Member

    Thanks. I will keep this as a separate issue for tracking. If your PR can fix #52008, you may want to link to it on your PR as well.

    Reproduced on Channel master, 3.24.0-1.0.pre.559.

  7. added
    a: text inputEntering text in a text field or keyboard related problems
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Aug 13, 2024
  8. simon-the-shark commented on Aug 13, 2024

    @simon-the-shark
    Author

    This is not my PR though :)

  9. huycozy commented on Aug 13, 2024

    @huycozy
    Member

    Oops, sorry. I should tag @zeqinjie

  10. added
    P2Important issues not at the top of the work list
    on Aug 15, 2024
  11. added
    r: fixedIssue is closed as already fixed in a newer version
    on Sep 27, 2024
  12. github-actions commented on Oct 11, 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.

  13. locked as resolved and limited conversation to collaborators on Oct 11, 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 lista: text inputEntering text in a text field or keyboard related problemsfound in release: 3.24Found to occur in 3.24frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-text-inputOwned by Text Input teamtriaged-text-inputTriaged by Text Input team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions