Repository: flutter
Issue: No good way to get line metrics for `Text`/`TextField` based widgets.
Labels: framework,a: typography,has reproducible steps,P2,found in release: 3.13,found in release: 3.14,team-text-input,triaged-text-input

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

1. Create the TextField whose size fills the screen.
2. Get the line counts from TextPainter.
```dart
  void updateDisplayedLineCount() {
    final text = _controller.text;
    final textPainter = TextPainter(
      text: TextSpan(text: text),
      textDirection: TextDirection.ltr,
      maxLines: null,
    );

    textPainter.layout(maxWidth: MediaQuery.of(context).size.width);

    setState(() {
      displayedLineCount = textPainter.computeLineMetrics().length;
    });
  }
```

### Expected results

I expected to equal the display line count and the value of ```computeLineMetrics returned```.

### Actual results

Actual, The value of ```computeLineMetrics returned``` is wrong to the display line count.
![image](https://github.com/flutter/flutter/assets/56541594/6c693a16-ebf5-4ddc-afd1-056b20315d3f)
![image](https://github.com/flutter/flutter/assets/56541594/292b61fc-5982-464f-ae40-59405ed18ab8)

I think this issue similar to [the issue](https://github.com/flutter/flutter/issues/132198), but my issue occurred only 1 byte characters.


### Code sample

<details><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

class LineCountTextField extends StatefulWidget {
  @override
  _LineCountTextFieldState createState() => _LineCountTextFieldState();
}

class _LineCountTextFieldState extends State<LineCountTextField> {
  TextEditingController _controller = TextEditingController();
  int displayedLineCount = 1;

  @override
  void initState() {
    super.initState();
    _controller.addListener(updateDisplayedLineCount);
  }

  void updateDisplayedLineCount() {
    final text = _controller.text;
    final textPainter = TextPainter(
      text: TextSpan(text: text),
      textDirection: TextDirection.ltr,
      maxLines: null,
    );

    textPainter.layout(maxWidth: MediaQuery.of(context).size.width);

    setState(() {
      displayedLineCount = textPainter.computeLineMetrics().length;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        TextField(
          controller: _controller,
          maxLines: null,
        ),
        Text('Displayed Line Count: $displayedLineCount'),
      ],
    );
  }
}

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(title: Text('Line Count TextField Example')),
      body: LineCountTextField(),
    ),
  ));
}

```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

![flutter_issue](https://github.com/flutter/flutter/assets/56541594/97b5c3ff-0492-4793-95cc-07219a1888b6)


</details>


### Logs

<details><summary>Logs</summary>

```console
```
[log.txt](https://github.com/flutter/flutter/files/12505203/log.txt)


</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.10.5, on Microsoft Windows [Version 10.0.22621.2134], locale ja-JP)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.3)
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.80.1)
[√] Connected device (5 available)
[√] Network resources

• No issues found!
```

</details>