flutter_apopen 0.0.6

  • Readme
  • Changelog
  • Example
  • Installing
  • 54

official documents #

Before use Apopen,please read the official documents.

support #

  • Share Text
  • Share ImageUrl
  • Share Image with UInt8List(byte[])
  • Share WebPage(ImageUrl)
  • Share WebPage(Image with UInt8List(byte[]))

Dependencies #

Add the following dependencies in your pubspec.yaml file:

dependencies:
  flutter_apopen: ^${latestVersion}

Register ApOpenSDK via flutter_apopen #

    import 'package:flutter_apopen/flutter_apopen.dart' as apopen;
    apopen.registerAP(appId: "2019111369123863");

Share #

ShareText #

  void shareText() async {
    var result = await apopen.shareText('This is a Share Text');
    print(result);
  } 

ShareText #

  void shareText() async {
    var result = await apopen.shareText('This is a Share Text');
    print(result);
  } 

ShareImageUrl #

  void shareImageUrl() async{
    var result = await apopen.shareImageUrl('http://XXX.jpg');
    print(result);
  }

ShareImageData #

  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);
  }

ShareWebWithImageData #

    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);    
    }

ShareWebWithImageUrl #

    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);
    }    

0.0.6 #

  • TODO: Change the kotlin version.

example/lib/main.dart

import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_apopen/flutter_apopen.dart' as apopen;


void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  void initState() {
    super.initState();
    registerApOpen();
  }
  registerApOpen() async{
    var result = await apopen.registerAP(appId: "2019111369123863");
    print(result);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('AliPay Share'),
        ),
        body: new Container(
          child: new ListView(
            children: <Widget>[
              ListTile(
                title: new Text(
                  'Share Text'
                ),
                onTap: shareText,
              ),
              ListTile(
                title: new Text(
                  'Share Image with URL'
                ),
                onTap: shareImageUrl,
              ),
              ListTile(
                title: new Text(
                  'Share Image with Data'
                ),
                onTap: shareImageData,
              ),
              ListTile(
                title: new Text(
                  'Share Image with URL'
                ),
                onTap: shareWebWithImageData,
              ),
              ListTile(
                title: new Text(
                  'Share Image with Data'
                ),
                onTap: shareWebWithImageUrl,
              ),              
            ],
          ),
        )
      ),
    );
  }

  void shareText() async {
    var result = await apopen.shareText('这是一条分享信息');
    print(result);
  } 

  void shareImageUrl() async{
    var result = await apopen.shareImageUrl('http://cdn6.hbimg.cn/store/tuku/310_999/bigfiles/200948/887EDAB4E8C49EB182F1D5CF4AAF88.jpg');
    print(result);    
  }

  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);    
  }  

  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.baidu.com',
      title: '测试标题',
      desc: '测试描述',
      );
    print(result);        
  }
  void shareWebWithImageUrl() async{
    var result = await apopen.shareWebAndImgUrl(
      imageUrl: 'http://cdn6.hbimg.cn/store/tuku/310_999/bigfiles/200948/887EDAB4E8C49EB182F1D5CF4AAF88.jpg',
      wepageUrl: 'https://www.baidu.com',
      title: '测试标题',
      desc: '测试描述',
      );
    print(result);  
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_apopen: ^0.0.6

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_apopen/flutter_apopen.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
19
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
77
Overall:
Weighted score of the above. [more]
54
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:flutter_apopen/flutter_apopen.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:flutter_apopen/flutter_apopen.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:flutter_apopen/flutter_apopen.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:flutter_apopen/flutter_apopen.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [flutter_apopen] that is in a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

8 out of 8 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/apopen_iml.dart. (-1 points)

Analysis of lib/src/apopen_iml.dart reported 2 hints:

line 41 col 5: The type parameter 'wepageUrl' is annotated with @required but only named parameters without a default value can be annotated with it.

line 59 col 5: The type parameter 'wepageUrl' is annotated with @required but only named parameters without a default value can be annotated with it.

Maintenance suggestions

The package description is too short. (-13 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test