Skip to content

Commit 45accd3

Browse files
committed
fix format for platform interface
1 parent ed53af0 commit 45accd3

1 file changed

Lines changed: 27 additions & 18 deletions

File tree

packages/share_plus/share_plus_platform_interface/lib/method_channel/method_channel_share.dart

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,26 @@ import 'package:uuid/uuid.dart';
1616
class MethodChannelShare extends SharePlatform {
1717
/// [MethodChannel] used to communicate with the platform side.
1818
@visibleForTesting
19-
static const MethodChannel channel =
20-
MethodChannel('dev.fluttercommunity.plus/share');
19+
static const MethodChannel channel = MethodChannel(
20+
'dev.fluttercommunity.plus/share',
21+
);
2122

2223
@override
2324
Future<ShareResult> share(ShareParams params) async {
2425
final paramsMap = await _toPlatformMap(params);
25-
final result = await channel.invokeMethod<String>('share', paramsMap) ??
26+
final result =
27+
await channel.invokeMethod<String>('share', paramsMap) ??
2628
'dev.fluttercommunity.plus/share/unavailable';
2729

2830
return ShareResult(result, _statusFromResult(result));
2931
}
3032

3133
Future<Map<String, dynamic>> _toPlatformMap(ShareParams params) async {
3234
assert(
33-
params.text != null ||
34-
params.uri != null ||
35-
(params.files != null && params.files!.isNotEmpty),
36-
'At least one of text, uri or files must be provided',
35+
params.text != null ||
36+
params.uri != null ||
37+
(params.files != null && params.files!.isNotEmpty),
38+
'At least one of text, uri or files must be provided',
3739
);
3840

3941
final map = <String, dynamic>{
@@ -51,8 +53,10 @@ class MethodChannelShare extends SharePlatform {
5153
}
5254

5355
if (params.files != null) {
54-
final filesWithPath =
55-
await _getFiles(params.files!, params.fileNameOverrides);
56+
final filesWithPath = await _getFiles(
57+
params.files!,
58+
params.fileNameOverrides,
59+
);
5660
assert(filesWithPath.every((element) => element.path.isNotEmpty));
5761

5862
final mimeTypes = filesWithPath
@@ -69,8 +73,9 @@ class MethodChannelShare extends SharePlatform {
6973

7074
if (params.excludedCupertinoActivities != null &&
7175
params.excludedCupertinoActivities!.isNotEmpty) {
72-
final excludedActivityTypes =
73-
params.excludedCupertinoActivities!.map((e) => e.value).toList();
76+
final excludedActivityTypes = params.excludedCupertinoActivities!
77+
.map((e) => e.value)
78+
.toList();
7479
map['excludedCupertinoActivities'] = excludedActivityTypes;
7580
}
7681

@@ -85,7 +90,8 @@ class MethodChannelShare extends SharePlatform {
8590
/// then make new file in TemporaryDirectory and return with path
8691
/// the system will automatically delete files in this
8792
/// TemporaryDirectory as disk space is needed elsewhere on the device
88-
Future<XFile> _getFile(XFile file, {
93+
Future<XFile> _getFile(
94+
XFile file, {
8995
String? tempRoot,
9096
String? nameOverride,
9197
}) async {
@@ -95,8 +101,8 @@ class MethodChannelShare extends SharePlatform {
95101
tempRoot ??= (await getTemporaryDirectory()).path;
96102
// Method returns null as in v2.0.0
97103
final extension =
98-
// ignore: dead_null_aware_expression
99-
extensionFromMime(file.mimeType ?? 'octet-stream') ?? 'bin';
104+
// ignore: dead_null_aware_expression
105+
extensionFromMime(file.mimeType ?? 'octet-stream') ?? 'bin';
100106

101107
//By having a UUID v4 folder wrapping the file
102108
//This path generation algorithm will not only minimize the risk of name collision but also ensure that the filename
@@ -113,7 +119,8 @@ class MethodChannelShare extends SharePlatform {
113119

114120
//Per Issue [#3032](https://github.com/fluttercommunity/plus_plugins/issues/3032): use overridden name when available.
115121
//Per Issue [#1548](https://github.com/fluttercommunity/plus_plugins/issues/1548): attempt to use XFile.name when available
116-
final filename = nameOverride ??
122+
final filename =
123+
nameOverride ??
117124
(filenameNotEmptyOrHasValidExt
118125
? file.name
119126
: "${const Uuid().v1().substring(10)}.$extension");
@@ -128,14 +135,16 @@ class MethodChannelShare extends SharePlatform {
128135
}
129136

130137
/// A wrapper of [MethodChannelShare._getFile] for multiple files.
131-
Future<List<XFile>> _getFiles(List<XFile> files,
132-
List<String>? fileNameOverrides,) async {
138+
Future<List<XFile>> _getFiles(
139+
List<XFile> files,
140+
List<String>? fileNameOverrides,
141+
) async {
133142
return Future.wait([
134143
for (var index = 0; index < files.length; index++)
135144
_getFile(
136145
files[index],
137146
nameOverride: fileNameOverrides?.elementAt(index),
138-
)
147+
),
139148
]);
140149
}
141150

0 commit comments

Comments
 (0)