Skip to content
Merged
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
4 changes: 2 additions & 2 deletions packages/share_plus/share_plus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Sharing files is not supported on Linux.

## Requirements

- Flutter >=3.41.0
- Dart >=3.11.0 <4.0.0
- Flutter >=3.38.1
- Dart >=3.10.0 <4.0.0
- iOS >=13.0
- macOS >=10.15
- Java 17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,28 @@ void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

testWidgets('Can launch share', (WidgetTester tester) async {
final params = ShareParams(
text: 'message',
subject: 'title',
);
final params = ShareParams(text: 'message', subject: 'title');
// Check isNotNull because we cannot wait for ShareResult
expect(SharePlus.instance.share(params), isNotNull);
});

testWidgets('Can launch shareUri', (WidgetTester tester) async {
final params = ShareParams(
uri: Uri.parse('https://example.com'),
);
final params = ShareParams(uri: Uri.parse('https://example.com'));
// Check isNotNull because we cannot wait for ShareResult
expect(SharePlus.instance.share(params), isNotNull);
}, skip: !Platform.isAndroid && !Platform.isIOS);

testWidgets('Can shareXFile created using File.fromData()',
(WidgetTester tester) async {
testWidgets('Can shareXFile created using File.fromData()', (
WidgetTester tester,
) async {
final bytes = Uint8List.fromList([1, 2, 3, 4, 5, 6, 7, 8]);
final XFile file =
XFile.fromData(bytes, name: 'image.jpg', mimeType: 'image/jpeg');

final params = ShareParams(
files: [file],
text: 'message',
final XFile file = XFile.fromData(
bytes,
name: 'image.jpg',
mimeType: 'image/jpeg',
);

final params = ShareParams(files: [file], text: 'message');
expect(SharePlus.instance.share(params), isNotNull);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ class _ExcludedActivityTypePageState
final List<CupertinoActivityType> tempSelected = [];
for (final String type in selected) {
tempSelected.add(
CupertinoActivityType.values
.firstWhere((e) => e.value == type),
CupertinoActivityType.values.firstWhere(
(e) => e.value == type,
),
);
}
Navigator.pop(context, tempSelected);
Expand Down
22 changes: 11 additions & 11 deletions packages/share_plus/share_plus/example/lib/image_previews.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ class ImagePreviews extends StatelessWidget {

final imageWidgets = <Widget>[];
for (var i = 0; i < imagePaths.length; i++) {
imageWidgets.add(_ImagePreview(
imagePaths[i],
onDelete: onDelete != null ? () => onDelete!(i) : null,
));
imageWidgets.add(
_ImagePreview(
imagePaths[i],
onDelete: onDelete != null ? () => onDelete!(i) : null,
),
);
}

return SingleChildScrollView(
Expand All @@ -50,20 +52,18 @@ class _ImagePreview extends StatelessWidget {
child: Stack(
children: <Widget>[
ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 200,
maxHeight: 200,
),
constraints: const BoxConstraints(maxWidth: 200, maxHeight: 200),
child: kIsWeb ? Image.network(imagePath) : Image.file(imageFile),
),
Positioned(
right: 0,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: FloatingActionButton(
backgroundColor: Colors.red,
onPressed: onDelete,
child: const Icon(Icons.delete)),
backgroundColor: Colors.red,
onPressed: onDelete,
child: const Icon(Icons.delete),
),
),
),
],
Expand Down
18 changes: 6 additions & 12 deletions packages/share_plus/share_plus/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ class MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Share Plus Plugin Demo'),
elevation: 4,
),
appBar: AppBar(title: const Text('Share Plus Plugin Demo'), elevation: 4),
body: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Column(
Expand Down Expand Up @@ -143,7 +140,8 @@ class MyHomePageState extends State<MyHomePage> {
extensions: <String>['jpg', 'jpeg', 'png', 'gif'],
);
final file = await openFile(
acceptedTypeGroups: <XTypeGroup>[typeGroup]);
acceptedTypeGroups: <XTypeGroup>[typeGroup],
);
if (file != null) {
setState(() {
imagePaths.add(file.path);
Expand Down Expand Up @@ -316,9 +314,7 @@ class MyHomePageState extends State<MyHomePage> {
);
scaffoldMessenger.showSnackBar(getResultSnackBar(shareResult));
} catch (e) {
scaffoldMessenger.showSnackBar(
SnackBar(content: Text('Error: $e')),
);
scaffoldMessenger.showSnackBar(SnackBar(content: Text('Error: $e')));
}
}

Expand All @@ -345,9 +341,7 @@ class MyHomePageState extends State<MyHomePage> {

scaffoldMessenger.showSnackBar(getResultSnackBar(shareResult));
} catch (e) {
scaffoldMessenger.showSnackBar(
SnackBar(content: Text('Error: $e')),
);
scaffoldMessenger.showSnackBar(SnackBar(content: Text('Error: $e')));
}
}

Expand All @@ -359,7 +353,7 @@ class MyHomePageState extends State<MyHomePage> {
children: [
Text("Share result: ${result.status}"),
if (result.status == ShareResultStatus.success)
Text("Shared to: ${result.raw}")
Text("Shared to: ${result.raw}"),
],
),
);
Expand Down
4 changes: 2 additions & 2 deletions packages/share_plus/share_plus/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ flutter:
- assets/flutter_logo.png

environment:
sdk: '>=3.4.0 <4.0.0'
flutter: '>=3.22.0'
sdk: '>=3.10.0 <4.0.0'
flutter: '>=3.38.1'
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import 'package:flutter_driver/flutter_driver.dart';

Future<void> main() async {
final driver = await FlutterDriver.connect();
final data =
await driver.requestData(null, timeout: const Duration(minutes: 1));
final data = await driver.requestData(
null,
timeout: const Duration(minutes: 1),
);
await driver.close();
final Map<String, dynamic> result = jsonDecode(data);
exit(result['result'] == 'true' ? 0 : 1);
Expand Down
6 changes: 3 additions & 3 deletions packages/share_plus/share_plus/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ dependencies:
url_launcher_platform_interface: ^2.3.2
ffi: ^2.2.0
web: ^1.1.1
win32: ^6.0.0
win32: ^6.0.1

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^6.0.0

environment:
sdk: ">=3.11.0 <4.0.0"
flutter: ">=3.41.0"
sdk: ">=3.10.0 <4.0.0"
flutter: ">=3.38.1"

Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ dev_dependencies:
flutter_lints: ^6.0.0

environment:
sdk: ">=3.11.0 <4.0.0"
flutter: ">=3.41.0"
sdk: ">=3.10.0 <4.0.0"
flutter: ">=3.38.1"
Loading