fix share PlatformException Non-empty title expected#7820
Conversation
… bar Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR fixes a
Confidence Score: 4/5Safe to merge — the crash fix in share.dart is correct and targeted, and the guard in ai_message.dart is a reasonable defensive addition. The conversation share fix precisely addresses the root cause: an empty string subject is now passed as null so the iOS plugin never sees it. The ai_message.dart guard is a defensive improvement but has a minor ordering issue where haptic feedback fires before the guard, giving users a phantom response on an unreachable edge case. An identical unguarded callsite in app_detail.dart with subject: app.name remains outside this PR's scope. app/lib/pages/chat/widgets/ai_message.dart — haptic order; app/lib/pages/apps/app_detail/app_detail.dart — similar unguarded subject pattern not addressed in this PR Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as Flutter UI
participant Share as share_plus (Dart)
participant MC as MethodChannelShare
participant iOS as FPPSharePlusPlugin (iOS)
Note over UI,iOS: BEFORE fix — crash path
UI->>Share: Share.share(content, subject: "")
Share->>MC: "invokeMethod('share', {text, subject: ""})"
MC->>iOS: platform call
iOS-->>MC: PlatformException("Non-empty title expected")
MC-->>UI: FlutterError crash
Note over UI,iOS: AFTER fix — share.dart
UI->>Share: Share.share(content, subject: null)
Share->>MC: "invokeMethod('share', {text})"
MC->>iOS: platform call
iOS-->>UI: share sheet displayed
Note over UI,iOS: AFTER fix — ai_message.dart guard
UI->>UI: if messageText.isEmpty return early
UI->>Share: Share.share(messageText)
Share->>iOS: platform call
iOS-->>UI: share sheet displayed
Reviews (1): Last reviewed commit: "fix pass null subject instead of empty s..." | Re-trigger Greptile |
| onTap: () async { | ||
| HapticFeedback.lightImpact(); | ||
| if (widget.messageText.isEmpty) return; | ||
| await Share.share(widget.messageText); |
There was a problem hiding this comment.
The haptic feedback fires before the
isEmpty guard, so if messageText is ever empty the user feels a tap response but nothing happens — no share sheet appears and no analytics are emitted. Moving the guard before the haptic keeps the feedback tied to the action actually executing.
| onTap: () async { | |
| HapticFeedback.lightImpact(); | |
| if (widget.messageText.isEmpty) return; | |
| await Share.share(widget.messageText); | |
| onTap: () async { | |
| if (widget.messageText.isEmpty) return; | |
| HapticFeedback.lightImpact(); | |
| await Share.share(widget.messageText); |
… share Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
kodjima33
left a comment
There was a problem hiding this comment.
Mobile bug fix: guard empty share subject/text causing PlatformException crash; conf 4/5
MethodChannelShare.share
FlutterError - PlatformException(error, Non-empty title expected, null, null)
package:share_plus_platform_interface/method_channel/method_channel_share.dart:25
https://console.firebase.google.com/u/0/project/based-hardware/crashlytics/app/ios:com.friend-app-with-wearable.ios12/issues/40d960fea757d7ea8a9d0c02bec36346?time=7d&types=crash&sessionEventKey=9c121cc3398445498d7d53cbf3c9f259_2228414962524742499
Logs:
Fix:
The iOS share_plus plugin (FPPSharePlusPlugin.m) throws PlatformException "Non-empty title expected" when the subject/title field is present in the method channel arguments but is an empty string rather than nil. Two code paths were addressed:
shareConversationLink in conversation_detail/share.dart: conversation.structured.title is "" for any conversation that has not yet been processed by the backend. Passing subject: "" sends an empty NSString to the iOS plugin, triggering the crash. Fixed by passing null when the title is empty so the key is omitted from the platform map entirely.
MessageActionBar share button in chat/widgets/ai_message.dart: added an explicit isEmpty guard before calling Share.share so a degenerate empty messageText can never reach the platform layer.
🤖 Generated with Claude Code