Skip to content

[Bug]: share_plus does not honour the mime type I have given in the XFile #3750

@miklcct

Description

@miklcct

Platform

Android 12

Plugin

share_plus

Version

12.0.1

Flutter SDK

3.35.7

Steps to reproduce

Share an XFile of JSON content with a custom mime type.

When the intent is opened in Intent Intercept, the mime type is always shown as application/json if the fileNameOverrides entry ends in .json, instead of the mime type given in the source code.

If I remove the fileNameOverrides parameter, the mime type is shown as application/octet-stream instead of my custom mime type, instead of the mime type given in the source code. If the mime type is a well-known one (e.g. text/plain or image/png ), it works correctly and the file extension is generated accordingly.

Code Sample

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:share_plus/share_plus.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'share_plus bug',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text("share_plus demonstration"),
      ),
      body: Center(
        child: Text(
          'Press the button to share a custom JSON',
          style: Theme.of(context).textTheme.titleMedium,
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          final params = ShareParams(
            files: [
              XFile.fromData(
                utf8.encode(jsonEncode([1, 2, 3, 'a', 'b', 'c'])),
                mimeType: 'application/vnd.test.share_plus+json',
              ),
            ],
            fileNameOverrides: ['example.json'],
          );

          SharePlus.instance.share(params);
        },
        tooltip: 'Share',
        child: const Icon(Icons.share),
      ),
    );
  }
}

Logs

[        ] Syncing files to device Nokia 5 4... (completed in 138ms)
[        ] Synced 0.0MB.
[        ] <- accept
[   +4 ms] Connected to _flutterView/0xb400007c22bdf360.
[   +1 ms] Flutter run key commands.
[        ] r Hot reload. 🔥🔥🔥
[        ] R Hot restart.
[        ] h List all available interactive commands.
[        ] d Detach (terminate "flutter run" but leave application running).
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).
[        ] A Dart VM Service on Nokia 5 4 is available at: http://127.0.0.1:42613/qS-ZnyKY_hQ=/
[+1208 ms] The Flutter DevTools debugger and profiler on Nokia 5 4 is available at: http://127.0.0.1:9102?uri=http://127.0.0.1:42613/qS-ZnyKY_hQ=/
[  +10 ms] I/Choreographer(17772): Skipped 199 frames!  The application may be doing too much work on its main thread.
[  +96 ms] I/AdrenoGLES-0(17772): QUALCOMM build                   : 2bd16eb911, I3687d7cf91
[        ] I/AdrenoGLES-0(17772): Build Date                       : 02/10/21
[        ] I/AdrenoGLES-0(17772): OpenGL ES Shader Compiler Version: EV031.32.02.08
[        ] I/AdrenoGLES-0(17772): Local Branch                     : 
[        ] I/AdrenoGLES-0(17772): Remote Branch                    : 
[        ] I/AdrenoGLES-0(17772): Remote Branch                    : 
[        ] I/AdrenoGLES-0(17772): Reconstruct Branch               : 
[        ] I/AdrenoGLES-0(17772): Build Config                     : S P 10.0.7 AArch64
[        ] I/AdrenoGLES-0(17772): Driver Path                      : /vendor/lib64/egl/libGLESv2_adreno.so
[   +7 ms] I/AdrenoGLES-0(17772): PFP: 0x016ee195, ME: 0x00000000
[  +19 ms] D/hw-ProcessState(17772): Binder ioctl to enable oneway spam detection failed: Invalid argument
[+5000 ms] D/ProfileInstaller(17772): Installing profile for com.example.share_plus_mime_bug
[+7848 ms] D/CompatibilityChangeReporter(17772): Compat change id reported: 160794467; UID 10207; state: ENABLED

Flutter Doctor

[✓] Flutter (Channel stable, 3.35.7, on Ubuntu 25.10 6.17.0-8-generic, locale en_GB.UTF-8) [175ms]
    • Flutter version 3.35.7 on channel stable at /home/michael/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision adc9010625 (3 months ago), 2025-10-21 14:16:03 -0400
    • Engine revision 035316565a
    • Dart version 3.9.2
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-lldb-debugging

[!] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [2.6s]
    • Android SDK at /home/michael/Android/Sdk
    • Emulator version 36.1.9.0 (build_id 13823996) (CL:N/A)
    • Platform android-36, build-tools 36.0.0
    • Java binary at: /usr/lib/jvm/java-17-openjdk-amd64/bin/java
      This JDK is specified by the JAVA_HOME environment variable.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 17.0.17+10-Ubuntu-125.10)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Chrome - develop for the web [135ms]
    • CHROME_EXECUTABLE = microsoft-edge

[✓] Linux toolchain - develop for Linux desktop [2.2s]
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1
    • OpenGL core renderer: llvmpipe (LLVM 20.1.8, 256 bits)
    • OpenGL core version: 4.5 (Core Profile) Mesa 25.2.3-1ubuntu1
    • OpenGL core shading language version: 4.50
    • OpenGL ES renderer: llvmpipe (LLVM 20.1.8, 256 bits)
    • OpenGL ES version: OpenGL ES 3.2 Mesa 25.2.3-1ubuntu1
    • OpenGL ES shading language version: OpenGL ES GLSL ES 3.20
    • GL_EXT_framebuffer_blit: yes
    • GL_EXT_texture_format_BGRA8888: yes

[!] Android Studio (not installed) [133ms]
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/linux-android-setup for detailed instructions).

[✓] IntelliJ IDEA Ultimate Edition (version 2025.3) [133ms]
    • IntelliJ at /opt/idea
    • Flutter plugin version 89.0.0
    • Dart plugin version 502.0.0

[✓] Connected device (3 available) [224ms]
    • Nokia 5 4 (mobile) • HZQL1849FAKC1001147 • android-arm64  • Android 12 (API 31)
    • Linux (desktop)    • linux               • linux-x64      • Ubuntu 25.10 6.17.0-8-generic
    • Chrome (web)       • chrome              • web-javascript • Microsoft Edge 144.0.3719.82

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

! Doctor found issues in 2 categories.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions