微信SDK flutter插件,支持Android和iOS
分享图片及链接暂时仅支持 网络图片 ,
iOS分享网络图片如果不是 HTTPS 的话可能会失败,因为iOS ATS问题。
微信分享返回的结果仅代表调用微信分享sdk是否成功,不代表用户确实分享出去了,
微信2018年05月16日调整分享政策。
无需配置
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:sy_flutter_wechat/sy_flutter_wechat.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
_register();
}
_register() async {
bool result = await SyFlutterWechat.register('wxf9909bde17439ac2');
print(result);
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: const Text('Plugin example app'),
),
body: new ListView(
padding: EdgeInsets.all(8.0),
children: <Widget>[
RaisedButton(
child: Text('分享文字'),
onPressed: () async {
bool res = await SyFlutterWechat.shareText('hello world',
shareType: SyShareType.session);
print('分享文字:' + res.toString());
},
),
RaisedButton(
child: Text('分享图片'),
onPressed: () async {
bool res = await SyFlutterWechat.shareImage(
'https://avatars0.githubusercontent.com/u/10024776',
shareType: SyShareType.timeline);
print('分享图片:' + res.toString());
},
),
RaisedButton(
child: Text('分享网页'),
onPressed: () async {
bool res = await SyFlutterWechat.shareWebPage(
'标题',
'描述',
'https://avatars0.githubusercontent.com/u/10024776',
'http://www.example.com',
shareType: SyShareType.session);
print('分享网页:' + res.toString());
},
),
RaisedButton(
child: Text('支付'),
onPressed: () async {
String payInfo =
'{"appid":"wxf9909bde17439ac2","partnerid":"1518469211","prepayid":"wx120649521695951d501636f91748325073","package":"Sign=WXPay","noncestr":"1541976592","timestamp":"1541976592","sign":"E760C99A1A981B9A7D8F17B08EF60FCC"}';
SyPayResult payResult = await SyFlutterWechat.pay(
SyPayInfo.fromJson(json.decode(payInfo)));
print(payResult);
},
),
],
),
),
);
}
}
#### 其它Flutter plugin
example/README.md
Demonstrates how to use the sy_flutter_wechat plugin.
For help getting started with Flutter, view our online documentation.
Add this to your package's pubspec.yaml file:
dependencies:
sy_flutter_wechat_183: ^0.1.5
You can install packages from the command line:
with Flutter:
$ flutter packages get
Alternatively, your editor might support flutter packages get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:sy_flutter_wechat_183/sy_flutter_wechat_183.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.1.5 | Nov 24, 2018 |
|
|
0.1.4 | Nov 24, 2018 |
|
|
0.1.3 | Nov 23, 2018 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
0
|
Health:
Code health derived from static analysis.
[more]
|
99
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
80
|
Overall:
Weighted score of the above.
[more]
|
46
|
We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
Document public APIs. (-1 points)
35 out of 35 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.
The description contains too many non-ASCII characters. (-20 points)
The site uses English as its primary language. The value of the description
field in your package's pubspec.yaml
field should primarily contain characters used in English.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.0.0-dev.68.0 <3.0.0 | ||
flutter | 0.0.0 | ||
Transitive dependencies | |||
collection | 1.14.11 | ||
meta | 1.1.6 | 1.1.7 | |
sky_engine | 0.0.99 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 |