appinioGmbH / flutter_packages

Dart and Flutter plugins/packages used and maintained by @appinioGmbH
193 stars 224 forks source link

share How to get the file path #38

Closed tudosxxx closed 1 year ago

tudosxxx commented 2 years ago

If the file field is added, an error will be reported final ImagePicker picker = ImagePicker(); XFile? image = await picker.pickImage(source: ImageSource.gallery); if (image != null) { File file = File(image.path); appinioSocialShare.shareToTwitter('aaaaaaa').then((value) { print('===================$value'); });

sadatd commented 1 year ago

Just tested it on android and it works fine. As argument to the filePath you should give String(yourImage.path), so code should look like this `

     ElevatedButton(
          onPressed: () async {
            var image = await ImagesPicker.pick(
              count: 1,
              pickType: PickType.image,
            );
            path = image?[0].path;
            await appinioSocialShare.shareToTwitter(
              'This is message',
              filePath: path,
            );
          },
          child: Text('Pick and Twit Image'),
        ),

`

NOTE: I'm using ImagesPicker package, but it should work with ImagePicker as well.