shareFacebookStory static method

Future<String?> shareFacebookStory(
  1. String imagePath,
  2. String backgroundTopColor,
  3. String backgroundBottomColor,
  4. String attributionURL, {
  5. String? appId,
})

Implementation

static Future<String?> shareFacebookStory(
    String imagePath,
    String backgroundTopColor,
    String backgroundBottomColor,
    String attributionURL,
    {String? appId}) async {
  Map<String, dynamic> args;
  if (Platform.isIOS) {
    args = <String, dynamic>{
      "stickerImage": imagePath,
      "backgroundTopColor": backgroundTopColor,
      "backgroundBottomColor": backgroundBottomColor,
      "attributionURL": attributionURL,
    };
  } else {
    File file = File(imagePath);
    Uint8List bytes = file.readAsBytesSync();
    var stickerdata = bytes.buffer.asUint8List();
    final tempDir = await getTemporaryDirectory();
    String stickerAssetName = 'stickerAsset.png';
    final Uint8List stickerAssetAsList = stickerdata;
    final stickerAssetPath = '${tempDir.path}/$stickerAssetName';
    file = await File(stickerAssetPath).create();
    file.writeAsBytesSync(stickerAssetAsList);
    args = <String, dynamic>{
      "stickerImage": stickerAssetName,
      "backgroundTopColor": backgroundTopColor,
      "backgroundBottomColor": backgroundBottomColor,
      "attributionURL": attributionURL,
      "appId": appId
    };
  }
  final String? response =
      await _channel.invokeMethod('shareFacebookStory', args);
  return response;
}