1

I'm converting some older Swift apps with Flutter. How can I create a "share" button using flutter that at least gets Facebook and Twitter and make it cross platform for my iOS and Android versions. Here is the Swift code I use....

let activityViewController : UIActivityViewController = UIActivityViewController(
            activityItems: [firstActivityItem, secondActivityItem, image], applicationActivities: nil)

        // This lines is for the popover you need to show in iPad
        activityViewController.popoverPresentationController?.sourceView = (self.shareBTN)

        // This line remove the arrow of the popover to show in iPad
        activityViewController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection()
        activityViewController.popoverPresentationController?.sourceRect = CGRect(x: 150, y: 150, width: 0, height: 0)
        actInd.stopAnimating()
        self.present(activityViewController, animated: true, completion: nil)
Charles Jr
  • 8,333
  • 15
  • 53
  • 74

2 Answers2

2

Check out the Flutter share plugin -- it might have what you need.

Collin Jackson
  • 110,240
  • 31
  • 221
  • 152
  • Thanks @CollinJackson Can I assume these plugins work similar to CocoaControls.com, i.e. custom libraries except for Flutter plugins? I'll make sure to bookmark the page! – Charles Jr Jul 10 '17 at 00:03
  • 1
    I'm not familiar with CocoaControls, but flutter/plugins is an open source repository of wrappers around native APIs and SDKs so you can easily use them in your flutter apps. It's maintained by the Flutter team; contributions are always welcome! – Collin Jackson Jul 10 '17 at 03:09
0

As of Oct 2018, the best way I found was from this SO post here How do I share an image on iOS and Android using Flutter? that requires you use the File Provider package and know a little about Android Studio customization. Look for the answer from Albert Lardizabal. Looks like he may be part of the team that made the awesome "Hamilton" Flutter app.

Charles Jr
  • 8,333
  • 15
  • 53
  • 74