flutter_apopen:轻松集成支付宝分享

GitHub在这里,时间原因,后续会更新功能,欢迎star,issues!

使用前请先阅读支付宝开放平台官方文档

功能:

  • 分享文字

  • 分享图片Url

  • 分享图片通过UInt8List

  • 分享网页(缩略图Url)

  • 分享网页(缩略图UInt8List)

Dependencies


dependencies:

  flutter_apopen: ^${latestVersion}

初始化注册:


    import 'package:flutter_apopen/flutter_apopen.dart' as apopen;

    apopen.registerAP(appId: "your app id");

分享:

支付宝9.9.5版本后,scene整合在了一起,所以会话和发布动态不做处理。

单独分享文字:


  void shareText() async {

    var result = await apopen.shareText('This is a Share Text');

    print(result);

  }

分享图片URL:


  void shareText() async {

    var result = await apopen.shareText('This is a Share Text');

    print(result);

  }

分享图片通过UInt8List:


  void shareImageData() async{

    String assetPath = 'images/test.png';

    ByteData byteData = await rootBundle.load(assetPath);

    Uint8List pngBytes = byteData.buffer.asUint8List();

    var result = await apopen.shareImageData(pngBytes);

    print(result);

  }

分享网页,缩略图Url


    void shareWebWithImageUrl() async{

      var result = await apopen.shareWebAndImgUrl(

        imageUrl: 'http://XXX.jpg',

        wepageUrl: 'https://www.XXX.com',

        title: 'Text Title',

        desc: 'Text desc',

        );

      print(result);

    }   

分享网页,缩略图UInt8List


    void shareWebWithImageData() async{

      String assetPath = 'images/test.png';

      ByteData byteData = await rootBundle.load(assetPath);

      Uint8List pngBytes = byteData.buffer.asUint8List();

      var result = await apopen.shareWebAndImgData(

        imageData: pngBytes,

        wepageUrl: 'https://www.XXX.com',

        title: 'Text Title',

        desc: 'Text desc',

        );

      print(result);   

    }

你可能感兴趣的:(flutter_apopen:轻松集成支付宝分享)