-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[share_plus] Breaking constraints on iPad in AppBar Action #305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@miquelbeltran Sorry I should have mentioned, that the bug only occurs on my iPad not on an iPhone emulator. Maybe an ipados specific label is appropriate? And it works fine with the old official "share" package. |
Good point, I will add a new label. I am not super aware of the difference between the two. |
btw, there was a new release that fixed a related bug #251 if you have the chance please let us know if the bug is still present. Thanks! |
Just tested 2.1.4, but it didn't change anything related to this bug. |
I have the same issue on iPad, even outside AppBar. share_plus:
git:
url: [email protected]:fluttercommunity/plus_plugins.git
ref: main
path: packages/share_plus/share_plus |
I just encountered this as well. Is there a last version that is known to work? |
@flbaue due to the problem, I use the "share" package and do not support the option on the web for now. Haven't tried to use both packages at the same time until now. |
I just saw that inside the example implementation they call the share sheet like this: ...
Builder(builder: (BuildContext context) {
return ElevatedButton(
onPressed: text.isEmpty && imagePaths.isEmpty
? null
: () => _onShare(context),
child: const Text('Share'),
);
},
),
...
void _onShare(BuildContext context) async {
// A builder is used to retrieve the context immediately
// surrounding the ElevatedButton.
//
// The context's `findRenderObject` returns the first
// RenderObject in its descendent tree when it's not
// a RenderObjectWidget. The ElevatedButton's RenderObject
// has its position and size after it's built.
final box = context.findRenderObject() as RenderBox?;
if (imagePaths.isNotEmpty) {
await Share.shareFiles(
imagePaths,
text: text,
subject: subject,
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
);
} else {
await Share.share(
text,
subject: subject,
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
);
}
} With the provided However, the log regarding the Maybe it should be better documented, that the |
In addition, the old native implementation from the Share package always sets the origin. If no origin was provided, it will be set to a zero rect. The new implementation leaves the property as See
|
share_plus: ^2.1.4 [✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.1 20G80 darwin-x64, locale zh-Hans-CN) iPad 14.7.1 I just encountered this as well. |
I'm encountering the exact same issue, only of iPadOS. It does not matter if the button to invoke the share sheet is placed inside the appbar or anywhere else on screen. Version: share_plus: ^2.1.4 |
I have this error |
Same error on Ipad here iOS 15 |
+1 am also experiencing this on iPad running iOS 15.1. Using the latest version of share_plus (3.0.4). If anyone has managed to work around this, please let me know! |
Also experiencing the same issue on iPad on iOS 15.0.1. The app hangs for a few seconds then I see this in the console: [LayoutConstraints] Unable to simultaneously satisfy constraints. Will attempt to recover by breaking constraint Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. |
For what it's worth, I also see the same problem if I go back to share 2.0.4 on iPadOS 15. I'm wondering if iPad OS changed something and broke a bunch of stuff. |
I have the same issue with iPad, share_plus 3.0.4 |
Thanks, I've adopted this approach, and it seems to resolve the issue for me. |
work in iPad iOS 15 in my app |
How did you solve this problem? When I run it on Android, there is no problem, but when I run it on the iPhone, it reports this error in pod install. . Thank you very much |
I also have this issue in iPad - this seems to work for me |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days |
This is still an open issue. If you're using an overflow action bar item to trigger the event, the render box does not work and we get the error as described above: #305 (comment) |
@lovelessX can you provide a code sample that triggers the issue? |
@miquelbeltran Here is a gist with the minimum amount necessary to make it break. https://gist.github.com/lovelessX/4b346ed179edf10a8b1aebf1a1586c32 This is using share_plus 4.0.8. The Share action is in the overflow menu as prescribed. This fails on iPad. |
I checked your code and you have an error in it. You are using the context of the MyHomePage, so the box calculation is wrong. If you wrap the PopupMenuButton with a Builder then it should work: Builder(
builder: (context) {
return PopupMenuButton(
onSelected: (PopupMenuItemOptions value) {
switch (value) {
case PopupMenuItemOptions.share:
final RenderBox box = context.findRenderObject() as RenderBox;
Share.share("Share this text", sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
break;
}
},
itemBuilder: (BuildContext context) {
return [
const PopupMenuItem(
value: PopupMenuItemOptions.share,
child: Text("Share"),
),
];
},
);
}
), |
Thank you for finding that. One weird thing is it doesn't break on Android or iOS. But this solution works. |
That's expected, the native share sheet works differently on iPad than on iPhone (and on Android). This is also documented in the share_plus readme: https://github.com/fluttercommunity/plus_plugins/blob/main/packages/share_plus/share_plus/README.md#ipad |
@miquelbeltran Hi! |
This is unrelated to the current issue. Open a new ticket with your question. |
I upgraded to v. 1.2.0 and issue |
System info
Issue occurs on: iPadOs
Plugin name: share_plus
Plugin version: 2.1.2
Flutter doctor output:
Steps to Reproduce
Error
main.dart
Logs
flutter run --verbose
The text was updated successfully, but these errors were encountered: