Skip to content
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

[Bug]: PDF Not Sent to Default Mail Client on macOS Using Chrome #3490

Open
8 tasks done
MGARockAByte opened this issue Feb 21, 2025 · 0 comments
Open
8 tasks done

[Bug]: PDF Not Sent to Default Mail Client on macOS Using Chrome #3490

MGARockAByte opened this issue Feb 21, 2025 · 0 comments
Labels
bug Something isn't working triage

Comments

@MGARockAByte
Copy link

Platform

Chrome Version 133.0.6943.54 on macOS 15.2 (24C101)

Plugin

share_plus

Version

10.1.4

Flutter SDK

3.27.0

Steps to reproduce

First, thank you for this great package.

I am trying to implement a feature that allows a PDF to be shared across various services. The PDF is successfully sent to all services except for one—the mail client. The issue arises when the PDF is not sent to my mail client. There have been rare occasions where the PDF was received, but these are infrequent.

The PDF is not sent to the default mail client. This issue seems to occur specifically on macOS when using Chrome and attempting to send the PDF to the default mail application on Mac. I have also run the application on a server to rule out issues related to running it on localhost.

I've attached a code sample that focusing on a simple PDF generation and sharing process.

Thank you for your help in resolving this issue!

Feel free to modify the content or add any additional details that might help in troubleshooting.

Code Sample

import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pw;
import 'package:share_plus/share_plus.dart';

void main() {
  runApp(MainApp());
}

class MainApp extends StatelessWidget {
  MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: ElevatedButton(
            onPressed: () async {
              final pdfData = await _generatePdf();
              var result = await Share.shareXFiles(
                [
                  XFile.fromData(
                    pdfData,
                    mimeType: 'application/pdf',
                    name: 'my_pdf.pdf',
                  )
                ],
                fileNameOverrides: ['my_pdf.pdf'],
              );
              print('Share result: $result');
            },
            child: const Text('Share'),
          ),
        ),
      ),
    );
  }

  final List<String> messages = List<String>.generate(5, (i) => "Message $i");

  Future<Uint8List> _generatePdf() async {
    final pdf = pw.Document();

    pdf.addPage(
      pw.Page(
        build: (pw.Context context) => pw.Column(
          children: messages.asMap().entries.map((entry) {
            final text = entry.value;

            return pw.Container(
              alignment: pw.Alignment.center,
              padding: const pw.EdgeInsets.all(10),
              child: pw.Text(
                text,
                style: const pw.TextStyle(color: PdfColors.black, fontSize: 14),
              ),
            );
          }).toList(),
        ),
      ),
    );

    return pdf.save();
  }
}

Logs

[ +384 ms] The Flutter DevTools debugger and profiler on Chrome is available at:
                    http://127.0.0.1:9102?uri=http://127.0.0.1:64409/TtiBTjiYDB8=
[+5367 ms] Helvetica has no Unicode support see https://github.com/DavBfr/dart_pdf/wiki/Fonts-Management
[+2323 ms] Share result: ShareResult(raw: dev.fluttercommunity.plus/share/unavailable, status:
ShareResultStatus.unavailable)

Flutter Doctor

[✓] Flutter (Channel stable, 3.24.4, on macOS 15.2 24C101 darwin-arm64 (Rosetta), locale de-DE)
    • Flutter version 3.24.4 on channel stable at /Users/xxx/fvm/versions/3.24.4
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 603104015d (4 months ago), 2024-10-24 08:01:25 -0700
    • Engine revision db49896cf2
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/madelmann/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)

[✓] VS Code (version 1.97.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.104.0

[✓] Connected device (4 available)
    • sdk gphone64 arm64 (mobile)         • emulator-5554                        • android-arm64  • Android 15 (API
      35) (emulator)
    • iPhone SE (3rd generation) (mobile) • D1FB36BF-BE64-4E85-957F-F742DD2ACBFA • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-18-2 (simulator)
    • Mac Designed for iPad (desktop)     • mac-designed-for-ipad                • darwin         • macOS 15.2
      24C101 darwin-arm64 (Rosetta)
    • Chrome (web)                        • chrome                               • web-javascript • Google Chrome
      133.0.6943.127

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Checklist before submitting a bug

  • I searched issues in this repository and couldn't find such bug/problem
  • I Google'd a solution and I couldn't find it
  • I searched on StackOverflow for a solution and I couldn't find it
  • I read the README.md file of the plugin
  • I'm using the latest version of the plugin
  • All dependencies are up to date with flutter pub upgrade
  • I did a flutter clean
  • I tried running the example project
@MGARockAByte MGARockAByte added bug Something isn't working triage labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

1 participant