Repository: flutter
Issue: RenderParagraph getOffsetForCaret does not work correct if it has WidgetSpan with height not set
Labels: framework,dependency: skia,a: typography,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.13,found in release: 3.16

### 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

Just follow the code, this issue is related to #98458 

### Expected results

`offset.dx = 31.3`

<img width="284" alt="image" src="https://github.com/flutter/flutter/assets/8380586/fa2b022c-26a0-4e52-bfbe-7b76eee23360">


### Actual results

if WidgetSpan's height is not set, the result is calculated without WidgetSpan

`offset.dx=13.7`

<img width="282" alt="image" src="https://github.com/flutter/flutter/assets/8380586/67c0d110-6271-4b60-81b4-5ca1f207794d">


### Code sample

<details><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:flutter/rendering.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> {
  final GlobalKey text = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Text.rich(TextSpan(
        children: <InlineSpan>[
          TextSpan(text:'a'),
          WidgetSpan(child: Container(width: 20)),    // if height is set, the result is correct
          TextSpan(text: 'c'),
        ]
      ), key:text,),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          RenderParagraph paragraph = text.currentContext!.findRenderObject()! as RenderParagraph;
          final String string = paragraph.text.toPlainText();
          final Offset offset = paragraph.getOffsetForCaret(TextPosition(offset: string.length, affinity: TextAffinity.upstream), Rect.zero);
          showDialog<void>(
            context: context,
            barrierDismissible: false,
            builder: (BuildContext context) {
              return AlertDialog(
                title: const Text('getOffsetForCaret'),
                content: SingleChildScrollView(
                  child: ListBody(
                    children: <Widget>[
                      Text('string is $string'),
                      Text('string length is ${string.length}'),
                      Text('getOffsetForCaret at location "${string.length}" is $offset'),
                    ],
                  ),
                ),
                actions: <Widget>[
                  TextButton(
                    child: const Text('Approve'),
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                  ),
                ],
              );
            },
          );
        },
        child: Icon(Icons.ice_skating),
      ),
    );
  }
}
```

</details>


### Screenshots or Video

_No response_

### Logs

_No response_

### Flutter Doctor output

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel wework-3.10.0, 3.10.2-0.0.pre.44, on macOS 13.5 22G74 darwin-arm64 (Rosetta), locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.1)
[✓] VS Code (version 1.79.2)