Skip to content

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

@simon-the-shark

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>

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