title: How do I share an image on iOS and Android using Flutter?
body: <p>I would like to share an image using the standard share dialogs in iOS and Android. The code below is mostly from <a href="https://pub.dartlang.org/packages/share" rel="noreferrer">https://pub.dartlang.org/packages/share</a> which I'm using as a starting point (only Dart and Objective-C below). It currently shares only text.</p>
  
  <p>Instead of Image below which I'm not sure is the best approach, how would I convert the image to a byte stream in Dart and handle in iOS and Android.</p>
  
  <p>Dart</p>
  
  <pre><code>static const _kShareChannel = const MethodChannel('example.test.com/share');
  Future&lt;Null&gt; shareImage(Image image) {
    assert(image != null);
    return _kShareChannel.invokeMethod('shareImage', image);
  }
  </code></pre>
  
  <p>Objective-C</p>
  
  <pre><code>static NSString *const PLATFORM_CHANNEL = @"example.test.com/share";
  
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      [GeneratedPluginRegistrant registerWithRegistry:self];
  
      FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController;
  
      FlutterMethodChannel *shareChannel = [FlutterMethodChannel methodChannelWithName:PLATFORM_CHANNEL
                              binaryMessenger:controller];
  
      [shareChannel setMethodCallHandler:^(FlutterMethodCall *call, FlutterResult result) {
          if ([@"shareImage" isEqualToString:call.method]) {
              [self share:call.arguments withController:[UIApplication sharedApplication].keyWindow.rootViewController];
              result(nil);
          } else {
              result([FlutterError errorWithCode:@"UNKNOWN_METHOD"
                                         message:@"Unknown share method called"
                                         details:nil]);
          }
      }];
      return [super application:application didFinishLaunchingWithOptions:launchOptions];
  }
  
  - (void)share:(id)sharedItems withController:(UIViewController *)controller {
      UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[ sharedItems ]
                                    applicationActivities:nil];
      [controller presentViewController:activityViewController animated:YES completion:nil];
  }
  </code></pre>