Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/share_plus/share_plus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 12.1.0
- **FEAT**(share_plus): Eligible user to share files via specific package name with their extras

## 12.0.1

- **FIX**(share_plus): Avoid crash on iOS 26 on iPhones with no sharePositionOrigin param([#3699](https://github.com/fluttercommunity/plus_plugins/issues/3699)). ([42b079bd](https://github.com/fluttercommunity/plus_plugins/commit/42b079bd5fa56c9983a5a4fcf351190884f5c540))
Expand Down
2 changes: 1 addition & 1 deletion packages/share_plus/share_plus/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'

android {
namespace 'dev.fluttercommunity.plus.share'
compileSdk = flutter.compileSdkVersion
compileSdk = 35

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ internal class Share(
val paths = (arguments["paths"] as List<*>?)?.filterIsInstance<String>()
val mimeTypes = (arguments["mimeTypes"] as List<*>?)?.filterIsInstance<String>()
val fileUris = paths?.let { getUrisForPaths(paths) }
val packageName = arguments["packageName"] as String?
val extras = (arguments["extras"] as List<*>?)?.filterIsInstance<Map<String, String>>()

// Create Share Intent
val shareIntent = Intent()
Expand All @@ -76,6 +78,8 @@ internal class Share(
putExtra(Intent.EXTRA_TEXT, uri ?: text)
if (!subject.isNullOrBlank()) putExtra(Intent.EXTRA_SUBJECT, subject)
if (!title.isNullOrBlank()) putExtra(Intent.EXTRA_TITLE, title)
if (!packageName.isNullOrBlank()) setPackage(packageName)
extras?.forEach { item -> putExtra(item.keys.first(), item.values.first()) }
}
} else {
when {
Expand Down Expand Up @@ -109,6 +113,8 @@ internal class Share(
if (!text.isNullOrBlank()) putExtra(Intent.EXTRA_TEXT, text)
if (!subject.isNullOrBlank()) putExtra(Intent.EXTRA_SUBJECT, subject)
if (!title.isNullOrBlank()) putExtra(Intent.EXTRA_TITLE, title)
if (!packageName.isNullOrBlank()) setPackage(packageName)
extras?.forEach { item -> putExtra(item.keys.first(), item.values.first()) }
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
}
Expand Down
33 changes: 32 additions & 1 deletion packages/share_plus/share_plus/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,27 @@ class MyHomePageState extends State<MyHomePage> {
},
),
const SizedBox(height: 16),
Builder(
builder: (BuildContext context) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
foregroundColor: Theme.of(context).colorScheme.onPrimary,
backgroundColor: Theme.of(context).colorScheme.primary,
),
onPressed: text.isEmpty && imagePaths.isEmpty
? null
: () => _onShareWithResult(
context,
packageName: 'com.whatsapp',
extras: [
{"jid": "628111555333@s.whatsapp.net"}
],
),
child: const Text('Share to Specific Package Name'),
);
},
),
const SizedBox(height: 16),
Builder(
builder: (BuildContext context) {
return ElevatedButton(
Expand Down Expand Up @@ -242,7 +263,11 @@ class MyHomePageState extends State<MyHomePage> {
}
}

void _onShareWithResult(BuildContext context) async {
void _onShareWithResult(
BuildContext context, {
String? packageName,
List<Map<String, dynamic>>? extras,
}) async {
// A builder is used to retrieve the context immediately
// surrounding the ElevatedButton.
//
Expand All @@ -267,6 +292,8 @@ class MyHomePageState extends State<MyHomePage> {
files: files,
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
excludedCupertinoActivities: [CupertinoActivityType.airDrop],
packageName: packageName,
extras: extras,
),
);
} else if (uri.isNotEmpty) {
Expand All @@ -277,6 +304,8 @@ class MyHomePageState extends State<MyHomePage> {
title: title.isEmpty ? null : title,
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
excludedCupertinoActivities: excludedCupertinoActivityType,
packageName: packageName,
extras: extras,
),
);
} else {
Expand All @@ -287,6 +316,8 @@ class MyHomePageState extends State<MyHomePage> {
title: title.isEmpty ? null : title,
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
excludedCupertinoActivities: excludedCupertinoActivityType,
packageName: packageName,
extras: extras,
),
);
}
Expand Down
7 changes: 4 additions & 3 deletions packages/share_plus/share_plus/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ description: Demonstrates how to use the share_plus plugin.
dependencies:
flutter:
sdk: flutter
share_plus: ^12.0.1
share_plus:
path: ../
image_picker: ^1.1.2
file_selector: ^1.0.3

Expand All @@ -24,5 +25,5 @@ flutter:
- assets/flutter_logo.png

environment:
sdk: '>=3.4.0 <4.0.0'
flutter: '>=3.22.0'
sdk: ">=3.4.0 <4.0.0"
flutter: ">=3.22.0"
9 changes: 6 additions & 3 deletions packages/share_plus/share_plus/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: share_plus
description: Flutter plugin for sharing content via the platform share UI, using the ACTION_SEND intent on Android and UIActivityViewController on iOS.
version: 12.0.1
version: 12.1.0
homepage: https://github.com/fluttercommunity/plus_plugins
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/share_plus/share_plus
issue_tracker: https://github.com/fluttercommunity/plus_plugins/labels/share_plus
Expand Down Expand Up @@ -35,7 +35,11 @@
sdk: flutter
flutter_web_plugins:
sdk: flutter
share_plus_platform_interface: ^6.1.0
share_plus_platform_interface:
hosted:
name: share_plus_platform_interface
url: http://pub.dev.internal

Check notice on line 41 in packages/share_plus/share_plus/pubspec.yaml

View workflow job for this annotation

GitHub Actions / Dart Analyzer

The 'http' protocol shouldn't be used because it isn't secure.

Try using a secure protocol, such as 'https'.
version: 6.2.0-package-name-rc.1
file: ">=6.1.4 <8.0.0"
url_launcher_web: ^2.3.2
url_launcher_windows: ^3.1.2
Expand All @@ -53,4 +57,3 @@
environment:
sdk: ">=3.4.0 <4.0.0"
flutter: ">=3.22.0"

Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 6.2.0
- **FEAT**(share_plus): packageName, allow user to share files to specific packages name
- **FEAT**(share_plus): extras, allow user to share files with specific packages name add their extras

## 6.1.0

- **FEAT**(share_plus): Added `excludedCupertinoActivities` share parameter ([#3376](https://github.com/fluttercommunity/plus_plugins/issues/3376)). ([f9fdadb4](https://github.com/fluttercommunity/plus_plugins/commit/f9fdadb41242ad2e36ddbf1ade82be6c5bb78ec4))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ class MethodChannelShare extends SharePlatform {
map['excludedCupertinoActivities'] = excludedActivityTypes;
}

if (params.packageName != null) {
map['packageName'] = params.packageName;
}

if (params.extras != null) {
map['extras'] = params.extras;
}

return map;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ class ShareParams {
/// Parameter ignored on other platforms.
final List<CupertinoActivityType>? excludedCupertinoActivities;

final String? packageName;

final List<Map<String, dynamic>>? extras;

ShareParams({
this.text,
this.subject,
Expand All @@ -154,6 +158,8 @@ class ShareParams {
this.downloadFallbackEnabled = true,
this.mailToFallbackEnabled = true,
this.excludedCupertinoActivities,
this.packageName,
this.extras,
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: share_plus_platform_interface
description: A common platform interface for the share_plus plugin.
version: 6.1.0
version: 6.2.0
homepage: https://github.com/fluttercommunity/plus_plugins
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/

Expand Down
Loading