I am using share_plus 4.0.10 to share a simple string of code and it works within an android emulator. However, upon posting the app to testflight for beta testing, the share button doesn't seem to work. It only shows airdrop as a share option, and pressing airdrop does nothing.The code is pretty simple. onPressed: () { Share.share('id',subject:'...')}
share_plus requires iPad users to provide the sharePositionOrigin parameter.
Without it, share_plus will not work on iPads and may cause a crash or letting the UI not responding.
To avoid that problem, provide the sharePositionOrigin.
For example:
// Use Builder to get the widget context
Builder(
builder: (BuildContext context) {
return ElevatedButton(
onPressed: () => _onShare(context),
child: const Text('Share'),
);
},
),
// _onShare method:
final box = context.findRenderObject() as RenderBox?;
await Share.share(
text,
subject: subject,
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
);
See the main.dart in the example for a complete example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With