-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
Platform
web
Plugin
share_plus
Version
10.0.2
Flutter SDK
3.24
Steps to reproduce
-
Run share_plus bundled example in Chrome.
The app does not load at all with a JS error in the console. (see logs below) -
With a minimum code sample (included), the issue demonstrated as well, but I was able get the Flutter app running after I did
flutter clean && flutter pub get
, The issue then demonstrated with a different error, this time in Flutter (see below). -
I also have a fairly large app where I cannot even run web build (see logs below)
I am able to run all three on Android / iOS and #3 on the web when I remove the share_plus dependency
Code Sample
import 'package:flutter/material.dart';
import 'package:share_plus/share_plus.dart';
void main() {
runApp(MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
));
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
Future<void> _handleShare() async {
final result = await Share.share(
'check out my website https://example.com',
subject: 'Test subject',
);
if (result.status == ShareResultStatus.success) {
print('Thank you for sharing my website!');
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Share Plus 10.0.2')),
body: Center(
child: FilledButton(
onPressed: _handleShare,
child: Text('Share'),
),
),
);
}
}
Logs
**1. JS Error, web does not load**
Uncaught TypeError: Cannot read properties of undefined (reading 'Symbol(_privateNames)')
at dart.privateName (dart_sdk.js:56:24)
at load__packages__flutter__src__material__constants_dart (constants.dart.lib.js:53:32)
at Object.execCb (require.js:1696:33)
at Module.check (require.js:883:51)
at Module.<anonymous> (require.js:1139:34)
at require.js:134:23
at require.js:1189:21
at each (require.js:59:31)
at Module.emit (require.js:1188:17)
at Module.check (require.js:938:30)
at Module.enable (require.js:1176:22)
at Module.init (require.js:788:26)
at callGetModule (require.js:1203:63)
at Object.completeLoad (require.js:1590:21)
at HTMLScriptElement.onScriptLoad (require.js:1717:29)
**2. Flutter Exception**
Launching lib/main.dart on Chrome in debug mode...
This app is linked to the debug service: ws://127.0.0.1:59615/YPqn-SbNGl4=/ws
Debug service listening on ws://127.0.0.1:59615/YPqn-SbNGl4=/ws
Connecting to VM Service at ws://127.0.0.1:59615/YPqn-SbNGl4=/ws
Connected to the VM Service.
TypeError: Cannot read properties of undefined (reading 'Share')
packages/share_plus_test/main.dart 19:32 _handleShare
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async
packages/share_plus_test/main.dart 18:28 [_handleShare]
packages/flutter/src/material/ink_well.dart 1170:21 handleTap
packages/flutter/src/gestures/recognizer.dart 351:24 invokeCallback
packages/flutter/src/gestures/tap.dart 656:11 handleTapUp
packages/flutter/src/gestures/tap.dart 313:5 [_checkUp]
packages/flutter/src/gestures/tap.dart 246:7 handlePrimaryPointer
packages/flutter/src/gestures/recognizer.dart 703:9 handleEvent
packages/flutter/src/gestures/pointer_router.dart 98:7 [_dispatch]
packages/flutter/src/gestures/pointer_router.dart 143:9 <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/linked_hash_map.dart 21:7 forEach
packages/flutter/src/gestures/pointer_router.dart 141:17 [_dispatchEventToRoutes]
packages/flutter/src/gestures/pointer_router.dart 127:7 route
packages/flutter/src/gestures/binding.dart 501:5 handleEvent
packages/flutter/src/gestures/binding.dart 481:14 dispatchEvent
packages/flutter/src/rendering/binding.dart 450:11 dispatchEvent
packages/flutter/src/gestures/binding.dart 426:7 [_handlePointerEventImmediately]
packages/flutter/src/gestures/binding.dart 389:5 handlePointerEvent
packages/flutter/src/gestures/binding.dart 336:7 [_flushPointerEventQueue]
packages/flutter/src/gestures/binding.dart 305:9 [_handlePointerDataPacket]
lib/_engine/engine/platform_dispatcher.dart 1423:5 invoke1
lib/_engine/engine/platform_dispatcher.dart 336:5 invokeOnPointerDataPacket
lib/_engine/engine/pointer_binding.dart 398:30 [_sendToFramework]
lib/_engine/engine/pointer_binding.dart 224:7 onPointerData
lib/_engine/engine/pointer_binding.dart 1042:20 <fn>
lib/_engine/engine/pointer_binding.dart 941:7 <fn>
lib/_engine/engine/pointer_binding.dart 534:9 loggedHandler
dart-sdk/lib/_internal/js_dev_runtime/patch/js_allow_interop_patch.dart 188:27 _callDartFunctionFast1
**3. Build error**
Launching lib/main.dart on Chrome in debug mode...
../../../../.pub-cache/hosted/pub.dev/share_plus-10.0.2/lib/src/share_plus_web.dart:36:18: Error: The method 'ShareData' isn't defined for the class 'SharePlusWebPlugin'.
- 'SharePlusWebPlugin' is from 'package:share_plus/src/share_plus_web.dart' ('../../../../.pub-cache/hosted/pub.dev/share_plus-10.0.2/lib/src/share_plus_web.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ShareData'.
final data = ShareData(
^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/share_plus-10.0.2/lib/src/share_plus_web.dart:42:29: Error: The method 'canShare' isn't defined for the class 'Navigator'.
Try correcting the name to the name of an existing method, or defining a method named 'canShare'.
canShare = _navigator.canShare(data);
^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/share_plus-10.0.2/lib/src/share_plus_web.dart:57:24: Error: The method 'share' isn't defined for the class 'Navigator'.
Try correcting the name to the name of an existing method, or defining a method named 'share'.
await _navigator.share(data).toDart;
^^^^^
../../../../.pub-cache/hosted/pub.dev/share_plus-10.0.2/lib/src/share_plus_web.dart:80:11: Error: 'ShareData' isn't a type.
final ShareData data;
^^^^^^^^^
... repeated for every use of Share in code...
Flutter Doctor
flutter doctor -v
[✓] Flutter (Channel stable, 3.24.0, on macOS 14.5 23F79 darwin-arm64, locale en-CZ)
• Flutter version 3.24.0 on channel stable at /opt/homebrew/Caskroom/flutter/1.22.6/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 80c2e84975 (3 weeks ago), 2024-07-30 23:06:49 +0700
• Engine revision b8800d88be
• Dart version 3.5.0
• DevTools version 2.37.2
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/lukasnevosad/Library/Android/sdk
• Platform android-34, build-tools 31.0.0
• ANDROID_HOME = /Users/lukasnevosad/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.1)
• 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 17.0.11+0-17.0.11b1207.24-11852314)
[✓] VS Code (version 1.92.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.94.0
[✓] Connected device (6 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 14 (API 34) (emulator)
• Lukas’s iPhone (mobile) • 00008120-00060C2911E0C01E • ios • iOS 17.5.1 21F90
• Lukas’s iPad (mobile) • d4caf5df1725164fd6a5d1b4e6c8ca8ec346de71 • ios • iOS 17.3.1 21D61
• macOS (desktop) • macos • darwin-arm64 • macOS 14.5 23F79 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.5 23F79 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.120
! Error: Lukas’s Apple Watch needs to connect to determine its availability. Check the connection between the device and its companion iPhone, and the connection between the
iPhone and Xcode. Both devices may also need to be restarted and unlocked. (code 1)
! Error: Browsing on the local area network for Bara’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
! Error: Browsing on the local area network for Lukas’s Apple Watch. Ensure the device is unlocked and discoverable via Bluetooth. (code -27)
[✓] Network resources
• All expected network resources are available.
• No issues found!
Checklist before submitting a bug
- I searched issues in this repository and couldn't find such bug/problem
- 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