Repository: flutter
Issue: flutter 3.10 for ios: Picture.toImage() The picture can only show part for large picture
Labels: platform-ios,framework,engine,a: images,has reproducible steps,P2,found in release: 3.10,team-ios,triaged-ios,found in release: 3.13

### 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. run the sample on ipad, click the top button `capture long picture`
2. go to gallery check the image
3. the image is cropped

### Expected results

The picture is complete and nothing is missing

### Actual results

The picture can only show part

### Code sample

<details><summary>Code sample</summary>

```dart
[Paste your code here]
import 'dart:math';
import 'dart:ui' as ui;

import 'package:flutter/material.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';

class CaptureScreenDemo extends StatefulWidget {
  static const String routeName = 'capture_screen';

  const CaptureScreenDemo({Key? key}) : super(key: key);

  @override
  CaptureScreenDemoState createState() => CaptureScreenDemoState();
}

class CaptureScreenDemoState extends State<CaptureScreenDemo> {
  final CaptureController _captureController = CaptureController();

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        ElevatedButton(
          onPressed: _captureAndSave,
          child: const Text('capture long picture'),
        ),
        Expanded(
          child: CaptureWidget(
              controller: _captureController,
              scrollable: true,
              child: Column(
                children: [
                  ...List.generate(20, (index) => _buildCard()),
                ],
              )),
        ),
      ],
    );
  }

  Future<ui.Image> buildImage() async {
    ui.Image image;
    try {
      var mediaQuery = MediaQuery.of(context);
      var dpi = mediaQuery.devicePixelRatio;
      image = await _captureController.captureImage(dpi*2);
    } catch (e) {
      image = await _captureController.captureImage(2);
    }
    return image;
  }

  List<Color> colors = [
    Colors.red,
    Colors.green,
    Colors.blue,
    Colors.yellow,
    Colors.pink,
    Colors.purple,
  ];

  Widget _buildCard() {
    return Container(
      decoration: BoxDecoration(
        color: colors[Random().nextInt(colors.length)],
        border: Border.all(color: Colors.black, width: 10),
      ),
      height: 400,
      child: const Center(),
    );
  }

  Future<void> _captureAndSave() async {
    var image = await buildImage();
    print('image ${image.width} ${image.height}');

    var byteData = await image.toByteData(format: ui.ImageByteFormat.png);
    var imageBytes = byteData?.buffer.asUint8List();
    if (imageBytes == null) {
      return;
    }
    var name = 'MyImage_${DateTime.now().millisecondsSinceEpoch}';
    await ImageGallerySaver.saveImage(
      imageBytes,
      name: name,
    );
    print('save success');
  }
}

class CaptureWidget extends StatelessWidget {
  final Widget child;
  final CaptureController controller;

  /// 背景色 不设置则背景透明
  final Color? backgroundColor;

  /// 内容是否可以滚动
  final bool scrollable;

  const CaptureWidget(
      {Key? key,
      required this.controller,
      required this.child,
      this.backgroundColor,
      this.scrollable = true})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    var repaintBoundary = RepaintBoundary(
      key: controller.key,
      child: backgroundColor == null
          ? child
          : Container(
              color: backgroundColor,
              child: child,
            ),
    );
    return scrollable
        ? SingleChildScrollView(child: repaintBoundary)
        : repaintBoundary;
  }
}

/// Screen shot capture controller
class CaptureController {
  CaptureController();

  final GlobalKey key = GlobalKey();

  Future<ui.Image> captureImage(double dpi) async {
    var currentContext = key.currentContext;
    if (currentContext == null) throw 'key.currentContext is null';
    var renderObject = currentContext.findRenderObject();
    if (renderObject! is! RenderRepaintBoundary) {
      throw '获取图片失败:${renderObject.runtimeType}';
    }
    var boundary = renderObject as RenderRepaintBoundary;
    try {
      return await boundary.toImage(pixelRatio: dpi);
    } catch (e) {
      ZLogger.log('captureImage $e');
      rethrow;
    }
  }

  Future<ui.Image> buildImage(BuildContext context) async {
    ui.Image image;
    try {
      var mediaQuery = MediaQuery.of(context);
      var dpi = mediaQuery.devicePixelRatio;
      image = await captureImage(dpi);
    } catch (e) {
      image = await captureImage(2);
    }
    return image;
  }
}
```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]
![IMG_0038](https://github.com/flutter/flutter/assets/17843738/b9e31152-567e-4a50-a04a-40dfde927408)
</details>



### Logs

<details><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[Paste your output here]
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel stable, 3.10.6, on macOS 13.0.1 22A400 darwin-x64, locale zh-Hans-CN)
    ! Warning: `dart` on your path resolves to /usr/local/Cellar/dart/2.18.7/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/jike/fvm/versions/3.10.6. Consider adding /Users/jike/fvm/versions/3.10.6/bin to the front of your path.
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.80.2)
[✓] Connected device (3 available)
[✓] Network resources

! Doctor found issues in 1 category.
```

</details>