plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Bug]: share_plus file sharing problems in Windows

Open TheLastFlame opened this issue 8 months ago • 7 comments

Platform

Windows 11

Plugin

share_plus

Version

11.0.0

Flutter SDK

3.29.3

Steps to reproduce

I have prepared a complete example illustrating all aspects of the problem.

  1. share1: Sending a file created via xFile.fromData is impossible. 1.1: If sent without text, there will be an empty window.

    Image

    Image

    1.2 If sent with text, only the text will be sent.

    Image

    Image

  2. share2: Sending a manually written file encounters undocumented limitations. 2.1: Sending a file without text is impossible.

    Image

    Image

    2.2 Sending with text works normally. 2.3 Sending with text and deleting the file leads to a result similar to 1.2: only the text will be sent.

  3. The results described for "without sending text" cease to be relevant after calling one of the methods for sending with text. share_plus tries to send the old text sent previously, even if it is not passed in the current call. The saved text is reset after a full restart of the program (not a hot restart).

Code Sample

import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:share_plus/share_plus.dart';
import 'package:path/path.dart' as path;

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

void share1([bool includeText = false]) async {
  final String testContent = 'Test';
  final Uint8List bytes = utf8.encode(testContent);

  final xfile = XFile.fromData(bytes);

  await SharePlus.instance.share(
    ShareParams(files: [xfile], text: includeText ? 'Test' : null),
  );
}

void share2([bool includeText = false, bool deleteFile = false]) async {
  final String testContent = 'Test';
  final Uint8List bytes = utf8.encode(testContent);

  final temp = (await getTemporaryDirectory()).path;
  final filePath = path.join(temp, 'test.txt');
  var file = File(filePath);
  await file.writeAsBytes(bytes);

  await SharePlus.instance.share(
    ShareParams(files: [XFile(filePath)], text: includeText ? 'Test' : null),
  );

  if (deleteFile) await file.delete();
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Column(
            spacing: 16,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(onPressed: share1, child: Text('Share1')),
              ElevatedButton(
                onPressed: () => share1(true),
                child: Text('Share1 with text'),
              ),
              ElevatedButton(onPressed: share2, child: Text('Share2')),
              ElevatedButton(
                onPressed: () => share2(true),
                child: Text('Share2 with text'),
              ),
              ElevatedButton(
                onPressed: () => share2(false, true),
                child: Text('Share2 with delete'),
              ),
              ElevatedButton(
                onPressed: () => share2(true, true),
                child: Text('Share2 with text and delete'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Logs

-

Flutter Doctor

-

Checklist before submitting a bug

  • [x] I searched issues in this repository and couldn't find such bug/problem
  • [x] I Google'd a solution and I couldn't find it
  • [x] I searched on StackOverflow for a solution and I couldn't find it
  • [x] I read the README.md file of the plugin
  • [x] I'm using the latest version of the plugin
  • [x] All dependencies are up to date with flutter pub upgrade
  • [x] I did a flutter clean
  • [x] I tried running the example project

TheLastFlame avatar May 05 '25 05:05 TheLastFlame

any update on this?

selvam920 avatar May 13 '25 13:05 selvam920

still how long is required to fix this issue developers?

selvam920 avatar Jun 04 '25 17:06 selvam920

@selvam920, it's been around for over a year. Accordingly, the package author is not particularly interested in the Windows platform. The most realistic option to fix it is to fix it yourself and file a pr

TheLastFlame avatar Jun 05 '25 01:06 TheLastFlame

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

github-actions[bot] avatar Sep 04 '25 00:09 github-actions[bot]

Still relevant

TheLastFlame avatar Sep 04 '25 06:09 TheLastFlame