-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
What is your question?
- I create a class and wanted to use "Share.shareXFiles".
- I add "import 'package:share_plus/share_plus.dart';"
- When writting this line : await Share.shareXFiles([XFile(filename)], I have this message : The method 'XFile' isn't defined for the type 'DataShareService'.
- So I have to add this import "import 'package:cross_file/cross_file.dart';"
- But now I have this message "package:cross_file/cross_file.dart Depend on referenced packages.dartdepend_on_referenced_packages"
In your example, you don't have the problem because XFile is referenced by this import : 'package:image_picker/image_picker.dart'
In the example below, I have commented the line of the import 'package:cross_file/cross_file.dart' so you can see the problem. If you uncomment the import 'package:cross_file/cross_file.dart'; you'll see the other message.
Thanks.
Code sample :
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:share_plus/share_plus.dart';
// TODO : uncomment the line below to refrence XFile
//import 'package:cross_file/cross_file.dart';
class DataShareService {
void sharingFile({
required String filename,
required BuildContext context,
required String subject,
}) async {
final box = context.findRenderObject() as RenderBox?;
await Share.shareXFiles([XFile(filename)],
subject: subject,
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size);
}
}
Checklist before submitting a question
- 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 am 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
Labels
questionFurther information is requestedFurther information is requested