Skip to content

[Bug]: [share_plus][web][iOS] ShareXFiles doesn't work after first call #1331

@novikov-studio

Description

@novikov-studio

Platform

iOS 15,0

Plugin

share_plus

Version

6.2.0

Flutter SDK

3.3.8

Steps to reproduce

  1. Open Example project in Android Studio on MacOS
  2. Add Additional run args
    --web-port=80 --web-hostname=0.0.0.0 --web-launch-url=http://localhost --web-renderer=canvaskit
  3. Run
  4. Open iOS Simulator (for me: iPhone 11 Pro & iOS15.0)
  5. Launch Safari in simulator and navigate to http://localhost
  6. Press "Share XFile from Assets" button
  7. In Share dialog choose "Save Image"
  8. Press "Share XFile from Assets" button again - no reaction

In console you can see "Unhandled Promise Rejection".

If you wrap Share.shareXFiles in try catch, you can see exception: "NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission".

It seems like first call does not return.

Code Sample

// See Example - _onShareXFileFromAsset() or my version
//
Future<void> _share() async {
  final buffer = await rootBundle.load('assets/test.jpg');

  final data = Uint8List.view(buffer.buffer);
  try {
    final file = XFile.fromData(
      data,
      mimeType: 'image/jpeg',
      name: 'test.jpg',
      lastModified: DateTime.now(),
      length: data.length,
    );

    final result = await Share.shareXFiles([file]);

    debugPrint('${result.status}');
  } on Object catch (e) {
    debugPrint('$e');
  }
}

Logs

[Log] NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission. (dart_sdk.js, line 29633)
[Error] Unhandled Promise Rejection: Error
	_throw (dart_sdk.js:20522)
	throwWithStackTrace (dart_sdk.js:20519)
	(анонимная функция) (dart_sdk.js:40848)
	_microtaskLoop (dart_sdk.js:40705)
	_startMicrotaskLoop (dart_sdk.js:40711)
	(анонимная функция) (dart_sdk.js:36447)
	promiseReactionJob

Flutter Doctor

[✓] Flutter (Channel stable, 3.3.8, on macOS 11.6 20G165 darwin-arm, locale ru-RU)
    • Flutter version 3.3.8 on channel stable at /Users/user/soft/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 52b3dc25f6 (4 days ago), 2022-11-09 12:09:26 +0800
    • Engine revision 857bd6b74c
    • Dart version 2.18.4
    • DevTools version 2.15.0

[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/user/Library/Android/sdk
    ✗ 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 13.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13A1030d
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] Connected device (3 available)
    • iPhone 11 Pro (mobile) • 1103C47D-8ADC-46E9-886F-481952BE71F3 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 11.6 20G165 darwin-arm
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 107.0.5304.110

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

Checklist before submitting a bug

  • I Google'd a solution and I couldn't find it
  • I searched on StackOverflow for a solution and I couldn't find it
  • I read the README.md file of the plugin
  • I'm using the latest version of the plugin
  • All dependencies are up to date with flutter pub upgrade
  • I did a flutter clean
  • I tried running the example project

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions