Skip to content

Share button in textfield menu crashes app on iPad #138550

@ueman

Description

@ueman

Is there an existing issue for this?

Steps to reproduce

Use the following code example below

  1. Run it on an iPad
  2. Type something into the text field
  3. Double tap on the entered code and use the share button

Basically do what the gif shows in the Add additional options in edit menu section of the release article here https://medium.com/flutter/whats-new-in-flutter-3-16-dba6cb1015d1 but on an iPad.

This can be reproduced on an iPad Simulator, too.

I suspect what's missing is what's described here. On an iPad, the share dialog needs to know where it should be shown. If nothing is passed for the position, it just crashes.

Looking at the source, it seems plausible.
The framework part doesn't pass source coordinates to the engine side:

await SystemChannels.platform.invokeMethod(
'Share.invoke',
text,
);

Taking a further look at the engine and there's also no source rectangle passed to the share dialog:

https://github.com/flutter/engine/blob/b37d8573df6ffa9106dc31788ec648f6e8607c58/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm#L155-L162

The relevant PRs that introduced this are #132599 and flutter/engine#44554. Based on those, I think @LouiseHsu could help here.

Expected results

I'm able to share the text

Actual results

App crashes

Code sample

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

const Color darkBlue = Color.fromARGB(255, 18, 32, 47);

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(
        scaffoldBackgroundColor: darkBlue,
      ),
      home: Scaffold(
        body: Center(
          child: TextField(),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.0, on macOS 14.0 23A344 darwin-arm64, locale en-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.84.1)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: tabletTablets and landscape phonesa: text inputEntering text in a text field or keyboard related problemsc: fatal crashCrashes that terminate the processengineflutter/engine related. See also e: labels.found in release: 3.16Found to occur in 3.16found in release: 3.17Found to occur in 3.17has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions