increase min sdk and apply new formatter
This commit is contained in:
@@ -17,49 +17,53 @@ part 'sharing_intent.g.dart';
|
||||
|
||||
final _sharingIntentTransformer =
|
||||
StreamTransformer<List<SharedFile>, ReceivedParameter>.fromHandlers(
|
||||
handleData: (files, sink) async {
|
||||
//For now only one file is supported to share with the app
|
||||
final data = files.firstOrNull;
|
||||
handleData: (files, sink) async {
|
||||
//For now only one file is supported to share with the app
|
||||
final data = files.firstOrNull;
|
||||
|
||||
if (data != null && data.value != null) {
|
||||
switch (data.type) {
|
||||
case SharedMediaType.TEXT:
|
||||
case SharedMediaType.URL:
|
||||
if (uri_to_file.isUriSupported(data.value!)) {
|
||||
final file = await uri_to_file.toFile(data.value!);
|
||||
final mimeType = mime.lookupMimeType(file.path);
|
||||
switch (mimeType) {
|
||||
case 'application/pdf':
|
||||
final content =
|
||||
await PDFDoc.fromFile(file).then((doc) => doc.text);
|
||||
sink.add(
|
||||
ReceivedParameter(content, KagiTool.summarizer.name),
|
||||
);
|
||||
default:
|
||||
logger.w('Unhandled mime type: $mimeType');
|
||||
}
|
||||
} else {
|
||||
sink.add(ReceivedParameter(data.value, null));
|
||||
if (data != null && data.value != null) {
|
||||
switch (data.type) {
|
||||
case SharedMediaType.TEXT:
|
||||
case SharedMediaType.URL:
|
||||
if (uri_to_file.isUriSupported(data.value!)) {
|
||||
final file = await uri_to_file.toFile(data.value!);
|
||||
final mimeType = mime.lookupMimeType(file.path);
|
||||
switch (mimeType) {
|
||||
case 'application/pdf':
|
||||
final content = await PDFDoc.fromFile(
|
||||
file,
|
||||
).then((doc) => doc.text);
|
||||
sink.add(
|
||||
ReceivedParameter(content, KagiTool.summarizer.name),
|
||||
);
|
||||
default:
|
||||
logger.w('Unhandled mime type: $mimeType');
|
||||
}
|
||||
} else {
|
||||
sink.add(ReceivedParameter(data.value, null));
|
||||
}
|
||||
default:
|
||||
logger.w('Unhandled media type: $data');
|
||||
}
|
||||
default:
|
||||
logger.w('Unhandled media type: $data');
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@Riverpod()
|
||||
Raw<Stream<ReceivedParameter>> sharingIntentStream(Ref ref) {
|
||||
final initialStream = FlutterSharingIntent.instance
|
||||
// ignore: discarded_futures
|
||||
.getInitialSharing()
|
||||
// ignore: discarded_futures
|
||||
.then((event) {
|
||||
FlutterSharingIntent.instance.reset();
|
||||
return event;
|
||||
}).asStream();
|
||||
final initialStream =
|
||||
FlutterSharingIntent.instance
|
||||
// ignore: discarded_futures
|
||||
.getInitialSharing()
|
||||
// ignore: discarded_futures
|
||||
.then((event) {
|
||||
FlutterSharingIntent.instance.reset();
|
||||
return event;
|
||||
})
|
||||
.asStream();
|
||||
|
||||
return ConcatStream(
|
||||
[initialStream, FlutterSharingIntent.instance.getMediaStream()],
|
||||
).transform(_sharingIntentTransformer);
|
||||
return ConcatStream([
|
||||
initialStream,
|
||||
FlutterSharingIntent.instance.getMediaStream(),
|
||||
]).transform(_sharingIntentTransformer);
|
||||
}
|
||||
|
||||
@@ -13,18 +13,19 @@ String _$sharingIntentStreamHash() =>
|
||||
@ProviderFor(sharingIntentStream)
|
||||
final sharingIntentStreamProvider =
|
||||
AutoDisposeProvider<Raw<Stream<ReceivedParameter>>>.internal(
|
||||
sharingIntentStream,
|
||||
name: r'sharingIntentStreamProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$sharingIntentStreamHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
sharingIntentStream,
|
||||
name: r'sharingIntentStreamProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$sharingIntentStreamHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef SharingIntentStreamRef
|
||||
= AutoDisposeProviderRef<Raw<Stream<ReceivedParameter>>>;
|
||||
typedef SharingIntentStreamRef =
|
||||
AutoDisposeProviderRef<Raw<Stream<ReceivedParameter>>>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
|
||||
Reference in New Issue
Block a user