Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share Plus doesnt work on TestFlight ios app flutter

Tags:

flutter

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:'...')}

like image 752
Basty b Avatar asked Oct 31 '25 13:10

Basty b


1 Answers

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.

like image 77
omid Avatar answered Nov 04 '25 09:11

omid