What changed, and why it matters
This commit fixes an iPad-specific bug where sharing text or files could fail or crash. The root cause was that the share sheet was being anchored to a rectangle covering most of the screen (the page context) instead of a small point, leaving no room for iPadOS to display the popover. The fix shrinks oversized anchor rectangles to a single point and silently ignores duplicate share attempts caused by rapid double-tapping. There is no security vulnerability here; it is a UI/UX stability fix.
No security action required. Treat as a normal bug-fix release for iPad sharing stability.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change modifies lib/utils/share_util.dart. It adds error handling for PlatformException messages starting with ‘sharePositionOrigin’, returning ShareResult.unavailable when a share sheet is already presented (e.g., after a quick double tap). It also detects when the computed sharePositionOrigin Rect covers more than half the screen on iOS and replaces it with a 1x1 point at the center, preventing iPadOS 17 from laying out a zero-width popover and throwing on subsequent shares.
Changed components
lib/utils/share_util.dartiOS/iPad share sheet presentationShareUtil.share()ShareUtil._sharePosition()Inspect captured patch +18 / −0
### lib/utils/share_util.dart
@@ -1,4 +1,6 @@
+import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
import 'package:share_plus/share_plus.dart';
import 'package:cross_file/cross_file.dart';
@@ -7,6 +9,13 @@ class ShareUtil {
Share.share(
text,
sharePositionOrigin: _sharePosition(context),
+ ).catchError(
+ // _sharePosition always gives a valid anchor, so on iOS this only means something is already
+ // presented on top, in practice a share sheet after a quick double tap. Drop the duplicate.
+ (Object _) => ShareResult.unavailable,
+ test: (error) =>
+ error is PlatformException &&
+ (error.message?.startsWith('sharePositionOrigin') ?? false),
);
}
@@ -50,6 +59,15 @@ class ShareUtil {
if (clipped.isEmpty) {
return fallback;
}
+
+ // A page context (rather than the tapped button's) gives a rect covering most of the screen,
+ // which leaves an iPad popover no room: iPadOS 17 lays the share sheet out 0pt wide and the
+ // next share throws. Anchor such rects at their centre.
+ if (defaultTargetPlatform == TargetPlatform.iOS &&
+ clipped.width > screen.width / 2 &&
+ clipped.height > screen.height / 2) {
+ return Rect.fromCenter(center: clipped.center, width: 1, height: 1);
+ }
return clipped;
}
}Why this scored 22/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.