Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
71564dad
Unverified
提交
71564dad
authored
3月 04, 2022
作者:
Alex Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🎨
Clean dart code formats
上级
07e02e08
全部展开
显示空白字符变更
内嵌
并排
正在显示
27 个修改的文件
包含
755 行增加
和
689 行删除
+755
-689
LICENSE
LICENSE
+1
-1
main.dart
example/lib/main.dart
+0
-0
auth_by_qr_code_page.dart
example/lib/pages/auth_by_qr_code_page.dart
+13
-12
launch_mini_program_page.dart
example/lib/pages/launch_mini_program_page.dart
+10
-8
pay_page.dart
example/lib/pages/pay_page.dart
+12
-13
send_auth_page.dart
example/lib/pages/send_auth_page.dart
+12
-10
share_image_page.dart
example/lib/pages/share_image_page.dart
+34
-28
share_mini_program_page.dart
example/lib/pages/share_mini_program_page.dart
+39
-39
share_music_page.dart
example/lib/pages/share_music_page.dart
+49
-48
share_text_page.dart
example/lib/pages/share_text_page.dart
+26
-32
share_video_page.dart
example/lib/pages/share_video_page.dart
+48
-48
share_web_page.dart
example/lib/pages/share_web_page.dart
+35
-38
sign_auto_deduct_page.dart
example/lib/pages/sign_auto_deduct_page.dart
+60
-30
subscribe_message_page.dart
example/lib/pages/subscribe_message_page.dart
+24
-13
widget_test.dart
example/test/widget_test.dart
+0
-1
fluwx.dart
lib/fluwx.dart
+5
-5
fluwx_iml.dart
lib/src/fluwx_iml.dart
+0
-0
wechat_response.dart
lib/src/response/wechat_response.dart
+78
-90
share_models.dart
lib/src/share/share_models.dart
+104
-101
wechat_enums.dart
lib/src/wechat_enums.dart
+8
-7
wechat_file.dart
lib/src/wechat_file.dart
+59
-48
fluwx_iml_test.dart
test/fluwx_iml_test.dart
+31
-23
wechat_response_test.dart
test/response/wechat_response_test.dart
+58
-52
wechat_share_image_model_test.dart
test/share/wechat_share_image_model_test.dart
+20
-17
wechat_share_mini_program_model_test.dart
test/share/wechat_share_mini_program_model_test.dart
+0
-2
wechat_share_text_model_test.dart
test/share/wechat_share_text_model_test.dart
+7
-7
wechat_image_test.dart
test/wechat_image_test.dart
+22
-16
没有找到文件。
LICENSE
浏览文件 @
71564dad
...
...
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [
yyyy] [name of copyright own
er]
Copyright [
2020] [OpenFlutt
er]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
...
...
example/lib/main.dart
浏览文件 @
71564dad
差异被折叠。
点击展开。
example/lib/auth_by_qr_code_page.dart
→
example/lib/
pages/
auth_by_qr_code_page.dart
浏览文件 @
71564dad
import
'dart:typed_data'
;
import
'package:flutter/material.dart'
;
import
'package:fluwx/fluwx.dart'
as
fluwx
;
class
AuthByQRCodePage
extends
StatefulWidget
{
const
AuthByQRCodePage
({
Key
?
key
})
:
super
(
key:
key
);
@override
_AuthByQRCodePageState
createState
()
=>
_AuthByQRCodePageState
();
}
class
_AuthByQRCodePageState
extends
State
<
AuthByQRCodePage
>
{
String
_status
=
"status"
;
String
_status
=
'status'
;
Uint8List
?
_image
;
@override
...
...
@@ -18,7 +19,7 @@ class _AuthByQRCodePageState extends State<AuthByQRCodePage> {
// fluwx.onAuthByQRCodeFinished.listen((data) {
// setState(() {
// _status =
"errorCode=>${data.errorCode}\nauthCode=>${data.authCode}"
;
// _status =
'errorCode=>${data.errorCode}\nauthCode=>${data.authCode}'
;
// });
// });
// fluwx.onAuthGotQRCode.listen((image) {
...
...
@@ -29,7 +30,7 @@ class _AuthByQRCodePageState extends State<AuthByQRCodePage> {
//
// fluwx.onQRCodeScanned.listen((scanned) {
// setState(() {
// _status =
"scanned"
;
// _status =
'scanned'
;
// });
// });
}
...
...
@@ -38,20 +39,20 @@ class _AuthByQRCodePageState extends State<AuthByQRCodePage> {
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"AuthByQRCode"
),
title:
Text
(
'AuthByQRCode'
),
),
body:
Column
(
children:
<
Widget
>[
Rais
edButton
(
Elevat
edButton
(
onPressed:
()
{
// fluwx.authByQRCode(
// appId:
"wxd930ea5d5a258f4f"
,
// scope:
"noncestr"
,
// nonceStr:
"nonceStr"
,
// timeStamp:
"1417508194"
,
// signature:
"429eaaa13fd71efbc3fd344d0a9a9126835e7303"
);
// appId:
'wxd930ea5d5a258f4f'
,
// scope:
'noncestr'
,
// nonceStr:
'nonceStr'
,
// timeStamp:
'1417508194'
,
// signature:
'429eaaa13fd71efbc3fd344d0a9a9126835e7303'
);
},
child:
Text
(
"AUTH NOW"
),
child:
Text
(
'AUTH NOW'
),
),
Text
(
_status
),
_qrCode
()
...
...
example/lib/launch_mini_program_page.dart
→
example/lib/
pages/
launch_mini_program_page.dart
浏览文件 @
71564dad
...
...
@@ -2,12 +2,14 @@ import 'package:flutter/material.dart';
import
'package:fluwx/fluwx.dart'
;
class
LaunchMiniProgramPage
extends
StatefulWidget
{
const
LaunchMiniProgramPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
_LaunchMiniProgramPageState
createState
()
=>
_LaunchMiniProgramPageState
();
}
class
_LaunchMiniProgramPageState
extends
State
<
LaunchMiniProgramPage
>
{
String
?
_result
=
"无"
;
String
?
_result
=
'无'
;
@override
void
initState
()
{
...
...
@@ -16,7 +18,7 @@ class _LaunchMiniProgramPageState extends State<LaunchMiniProgramPage> {
if
(
res
is
WeChatLaunchMiniProgramResponse
)
{
if
(
mounted
)
{
setState
(()
{
_result
=
"isSuccessful:
${res.isSuccessful}
"
;
_result
=
'isSuccessful:
${res.isSuccessful}
'
;
});
}
}
...
...
@@ -33,18 +35,18 @@ class _LaunchMiniProgramPageState extends State<LaunchMiniProgramPage> {
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
"Launch MiniProgrom"
),
title:
const
Text
(
'Launch MiniProgrom'
),
),
body:
Column
(
children:
<
Widget
>[
OutlineButton
(
Outline
d
Button
(
onPressed:
()
{
launchWeChatMiniProgram
(
username:
"gh_d43f693ca31f"
);
launchWeChatMiniProgram
(
username:
'gh_d43f693ca31f'
);
},
child:
const
Text
(
"Launch MiniProgrom"
),
child:
const
Text
(
'Launch MiniProgrom'
),
),
const
Text
(
"响应结果;"
),
Text
(
"
$_result
"
)
const
Text
(
'响应结果;'
),
Text
(
'
$_result
'
)
],
),
);
...
...
example/lib/pay_page.dart
→
example/lib/pa
ges/pa
y_page.dart
浏览文件 @
71564dad
...
...
@@ -5,14 +5,15 @@ import 'package:flutter/material.dart';
import
'package:fluwx/fluwx.dart'
as
fluwx
;
class
PayPage
extends
StatefulWidget
{
const
PayPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
_PayPageState
createState
()
=>
_PayPageState
();
}
class
_PayPageState
extends
State
<
PayPage
>
{
String
_url
=
"https://wxpay.wxutil.com/pub_v2/app/app_pay.php"
;
String
_result
=
"无"
;
String
_url
=
'https://wxpay.wxutil.com/pub_v2/app/app_pay.php'
;
String
_result
=
'无'
;
@override
void
initState
()
{
...
...
@@ -20,13 +21,13 @@ class _PayPageState extends State<PayPage> {
fluwx
.
weChatResponseEventHandler
.
listen
((
res
)
{
if
(
res
is
fluwx
.
WeChatPaymentResponse
)
{
setState
(()
{
_result
=
"pay :
${res.isSuccessful}
"
;
_result
=
'pay :
${res.isSuccessful}
'
;
});
}
});
// fluwx.responseFromPayment.listen((data) {
// setState(() {
// _result =
"${data.errCode}"
;
// _result =
'${data.errCode}'
;
// });
// });
}
...
...
@@ -34,12 +35,10 @@ class _PayPageState extends State<PayPage> {
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
"pay"
),
),
appBar:
AppBar
(
title:
const
Text
(
'pay'
)),
body:
Column
(
children:
<
Widget
>[
OutlineButton
(
Outline
d
Button
(
onPressed:
()
async
{
var
h
=
H
.
HttpClient
();
h
.
badCertificateCallback
=
(
cert
,
String
host
,
int
port
)
{
...
...
@@ -50,7 +49,7 @@ class _PayPageState extends State<PayPage> {
var
data
=
await
Utf8Decoder
().
bind
(
response
).
join
();
Map
<
String
,
dynamic
>
result
=
json
.
decode
(
data
);
print
(
result
[
'appid'
]);
print
(
result
[
"timestamp"
]);
print
(
result
[
'timestamp'
]);
fluwx
.
payWithWeChat
(
appId:
result
[
'appid'
].
toString
(),
...
...
@@ -62,12 +61,12 @@ class _PayPageState extends State<PayPage> {
sign:
result
[
'sign'
].
toString
(),
)
.
then
((
data
)
{
print
(
"---》
$data
"
);
print
(
'---》
$data
'
);
});
},
child:
const
Text
(
"pay"
),
child:
const
Text
(
'pay'
),
),
const
Text
(
"响应结果;"
),
const
Text
(
'响应结果;'
),
Text
(
_result
)
],
),
...
...
example/lib/
send_auth
.dart
→
example/lib/
pages/send_auth_page
.dart
浏览文件 @
71564dad
...
...
@@ -2,12 +2,14 @@ import 'package:flutter/material.dart';
import
'package:fluwx/fluwx.dart'
as
fluwx
;
class
SendAuthPage
extends
StatefulWidget
{
const
SendAuthPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
_SendAuthPageState
createState
()
=>
_SendAuthPageState
();
}
class
_SendAuthPageState
extends
State
<
SendAuthPage
>
{
String
?
_result
=
"无"
;
String
?
_result
=
'无'
;
@override
void
initState
()
{
...
...
@@ -15,7 +17,7 @@ class _SendAuthPageState extends State<SendAuthPage> {
fluwx
.
weChatResponseEventHandler
.
distinct
((
a
,
b
)
=>
a
==
b
).
listen
((
res
)
{
if
(
res
is
fluwx
.
WeChatAuthResponse
)
{
setState
(()
{
_result
=
"state :
${res.state}
\n
code:
${res.code}
"
;
_result
=
'state :
${res.state}
\n
code:
${res.code}
'
;
});
}
});
...
...
@@ -30,22 +32,22 @@ class _SendAuthPageState extends State<SendAuthPage> {
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
"Send Auth"
),
),
appBar:
AppBar
(
title:
const
Text
(
'Send Auth'
)),
body:
Column
(
children:
<
Widget
>[
OutlineButton
(
Outline
d
Button
(
onPressed:
()
{
fluwx
.
sendWeChatAuth
(
scope:
"snsapi_userinfo"
,
state:
"wechat_sdk_demo_test"
)
scope:
'snsapi_userinfo'
,
state:
'wechat_sdk_demo_test'
,
)
.
then
((
data
)
{});
},
child:
const
Text
(
"send auth"
),
child:
const
Text
(
'send auth'
),
),
const
Text
(
"响应结果;"
),
Text
(
"
$_result
"
)
const
Text
(
'响应结果;'
),
Text
(
'
$_result
'
)
],
),
);
...
...
example/lib/share_image_page.dart
→
example/lib/
pages/
share_image_page.dart
浏览文件 @
71564dad
...
...
@@ -2,17 +2,15 @@ import 'package:flutter/material.dart';
import
'package:fluwx/fluwx.dart'
;
class
ShareImagePage
extends
StatefulWidget
{
const
ShareImagePage
({
Key
?
key
})
:
super
(
key:
key
);
@override
_ShareImagePageState
createState
()
=>
_ShareImagePageState
();
}
class
_ShareImagePageState
extends
State
<
ShareImagePage
>
{
WeChatScene
scene
=
WeChatScene
.
SESSION
;
String
_imagePath
=
// "http://img-download.pchome.net/download/1k1/3a/3e/ofskcd-s1a.jpg"
"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534614311230&di=b17a892b366b5d002f52abcce7c4eea0&imgtype=0&src=http%3A%2F%2Fimg.mp.sohu.com%2Fupload%2F20170516%2F51296b2673704ae2992d0a28c244274c_th.png"
;
String
_response
=
""
;
String
_response
=
''
;
WeChatImage
?
source
;
WeChatImage
?
thumbnail
;
...
...
@@ -23,7 +21,7 @@ class _ShareImagePageState extends State<ShareImagePage> {
weChatResponseEventHandler
.
listen
((
res
)
{
if
(
res
is
WeChatShareResponse
)
{
setState
(()
{
_response
=
"state :
${res.isSuccessful}
"
;
_response
=
'state :
${res.isSuccessful}
'
;
});
}
});
...
...
@@ -31,16 +29,14 @@ class _ShareImagePageState extends State<ShareImagePage> {
@override
Widget
build
(
BuildContext
context
)
{
return
new
Scaffold
(
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
"shareImage"
),
title:
const
Text
(
'shareImage'
),
actions:
<
Widget
>[
IconButton
(
icon:
Icon
(
Icons
.
share
,
color:
Colors
.
white
,
icon:
Icon
(
Icons
.
share
,
color:
Colors
.
white
),
onPressed:
_shareImage
,
),
onPressed:
_shareImage
)
],
),
body:
Padding
(
...
...
@@ -48,56 +44,66 @@ class _ShareImagePageState extends State<ShareImagePage> {
child:
Column
(
children:
<
Widget
>[
TextField
(
decoration:
InputDecoration
(
labelText:
"图片地址(仅限网络)"
),
decoration:
InputDecoration
(
labelText:
'图片地址(仅限网络)'
),
controller:
TextEditingController
(
text:
"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534614311230&di=b17a892b366b5d002f52abcce7c4eea0&imgtype=0&src=http%3A%2F%2Fimg.mp.sohu.com%2Fupload%2F20170516%2F51296b2673704ae2992d0a28c244274c_th.png"
),
text:
'https://timgsa.baidu.com/timg'
'?image'
'&quality=80'
'&size=b9999_10000'
'&sec=1534614311230'
'&di=b17a892b366b5d002f52abcce7c4eea0'
'&imgtype=0'
'&src=http%3A%2F%2Fimg.mp.sohu.com%2Fupload%2F20170516%2F51296b2673704ae2992d0a28c244274c_th.png'
,
),
onChanged:
(
value
)
{
source
=
WeChatImage
.
network
(
value
);
},
keyboardType:
TextInputType
.
multiline
,
),
TextField
(
decoration:
InputDecoration
(
labelText:
"缩略地址"
),
controller:
TextEditingController
(
text:
"//images/logo.png"
),
decoration:
InputDecoration
(
labelText:
'缩略地址'
),
controller:
TextEditingController
(
text:
'//images/logo.png'
),
onChanged:
(
value
)
{
thumbnail
=
WeChatImage
.
asset
(
value
);
},
),
new
Row
(
Row
(
children:
<
Widget
>[
const
Text
(
"分享至"
),
const
Text
(
'分享至'
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
SESSION
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"会话"
)
},
),
const
Text
(
'会话'
)
],
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
TIMELINE
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"朋友圈"
)
},
),
const
Text
(
'朋友圈'
)
],
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
FAVORITE
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"收藏"
)
},
),
const
Text
(
'收藏'
)
],
)
],
...
...
example/lib/
share_mini_program
.dart
→
example/lib/
pages/share_mini_program_page
.dart
浏览文件 @
71564dad
...
...
@@ -8,78 +8,77 @@ class ShareMiniProgramPage extends StatefulWidget {
class
_ShareMiniProgramPageState
extends
State
<
ShareMiniProgramPage
>
{
WeChatScene
scene
=
WeChatScene
.
SESSION
;
String
_webPageUrl
=
"http://www.qq.com"
;
String
_thumbnail
=
"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534614311230&di=b17a892b366b5d002f52abcce7c4eea0&imgtype=0&src=http%3A%2F%2Fimg.mp.sohu.com%2Fupload%2F20170516%2F51296b2673704ae2992d0a28c244274c_th.png"
;
String
_title
=
"Fluwx"
;
String
_userName
=
"gh_d43f693ca31f"
;
String
_path
=
"/pages/media"
;
String
_description
=
"Fluwx"
;
@override
void
initState
()
{
super
.
initState
();
}
String
_webPageUrl
=
'http://www.qq.com'
;
String
_thumbnail
=
'https://timgsa.baidu.com/timg'
'?image'
'&quality=80'
'&size=b9999_10000'
'&sec=1534614311230'
'&di=b17a892b366b5d002f52abcce7c4eea0'
'&imgtype=0'
'&src=http%3A%2F%2Fimg.mp.sohu.com%2Fupload%2F20170516%2F51296b2673704ae2992d0a28c244274c_th.png'
;
String
_title
=
'Fluwx'
;
String
_userName
=
'gh_d43f693ca31f'
;
String
_path
=
'/pages/media'
;
String
_description
=
'Fluwx'
;
@override
Widget
build
(
BuildContext
context
)
{
return
new
Scaffold
(
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
"ShareMiniProgram"
),
title:
const
Text
(
'ShareMiniProgram'
),
actions:
<
Widget
>[
IconButton
(
icon:
Icon
(
Icons
.
share
,
color:
Colors
.
white
,
icon:
Icon
(
Icons
.
share
,
color:
Colors
.
white
),
onPressed:
_share
,
),
onPressed:
_share
)
],
),
body:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
new
ListView
(
child:
ListView
(
children:
<
Widget
>[
new
TextField
(
controller:
TextEditingController
(
text:
"http://www.qq.com"
),
TextField
(
controller:
TextEditingController
(
text:
'http://www.qq.com'
),
onChanged:
(
str
)
{
_webPageUrl
=
str
;
},
decoration:
InputDecoration
(
labelText:
"web page url"
),
decoration:
InputDecoration
(
labelText:
'web page url'
),
),
new
TextField
(
controller:
TextEditingController
(
text:
"gh_d43f693ca31f"
),
TextField
(
controller:
TextEditingController
(
text:
'gh_d43f693ca31f'
),
onChanged:
(
str
)
{
_userName
=
str
;
},
decoration:
InputDecoration
(
labelText:
"user name"
),
decoration:
InputDecoration
(
labelText:
'user name'
),
),
new
TextField
(
controller:
TextEditingController
(
text:
"/pages/media"
),
TextField
(
controller:
TextEditingController
(
text:
'/pages/media'
),
onChanged:
(
str
)
{
_path
=
str
;
},
decoration:
InputDecoration
(
labelText:
"user name"
),
decoration:
InputDecoration
(
labelText:
'user name'
),
),
new
TextField
(
controller:
TextEditingController
(
text:
"Fluwx"
),
TextField
(
controller:
TextEditingController
(
text:
'Fluwx'
),
onChanged:
(
str
)
{
_title
=
str
;
},
decoration:
InputDecoration
(
labelText:
"title"
),
decoration:
InputDecoration
(
labelText:
'title'
),
),
new
TextField
(
controller:
TextEditingController
(
text:
"Fluwx"
),
TextField
(
controller:
TextEditingController
(
text:
'Fluwx'
),
onChanged:
(
str
)
{
_description
=
str
;
},
decoration:
InputDecoration
(
labelText:
"description"
),
decoration:
InputDecoration
(
labelText:
'description'
),
),
new
TextField
(
controller:
TextEditingController
(
text:
"images/logo.png"
),
TextField
(
controller:
TextEditingController
(
text:
'images/logo.png'
),
onChanged:
(
str
)
{
_thumbnail
=
str
;
},
decoration:
InputDecoration
(
labelText:
"thumbnail"
),
decoration:
InputDecoration
(
labelText:
'thumbnail'
),
),
],
),
...
...
@@ -88,13 +87,14 @@ class _ShareMiniProgramPageState extends State<ShareMiniProgramPage> {
}
void
_share
()
{
var
model
=
new
WeChatShareMiniProgramModel
(
var
model
=
WeChatShareMiniProgramModel
(
webPageUrl:
_webPageUrl
,
userName:
_userName
,
title:
_title
,
path:
_path
,
description:
_description
,
thumbnail:
WeChatImage
.
network
(
_thumbnail
));
thumbnail:
WeChatImage
.
network
(
_thumbnail
),
);
shareToWeChat
(
model
);
}
}
example/lib/
share_music
.dart
→
example/lib/
pages/share_music_page
.dart
浏览文件 @
71564dad
...
...
@@ -2,118 +2,118 @@ import 'package:flutter/material.dart';
import
'package:fluwx/fluwx.dart'
;
class
ShareMusicPage
extends
StatefulWidget
{
const
ShareMusicPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
_ShareMusicPageState
createState
()
=>
_ShareMusicPageState
();
}
class
_ShareMusicPageState
extends
State
<
ShareMusicPage
>
{
String
_musicUrl
=
"http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3"
;
String
_musicLowBandUrl
=
"http://www.qq.com"
;
String
_title
=
"Beyond"
;
String
_description
=
"A Popular Rock Band From China"
;
String
_thumnail
=
"images/logo.png"
;
'http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3'
;
String
_musicLowBandUrl
=
'http://www.qq.com'
;
String
_title
=
'Beyond'
;
String
_description
=
'A Popular Rock Band From China'
;
String
_thumnail
=
'images/logo.png'
;
WeChatScene
scene
=
WeChatScene
.
SESSION
;
@override
void
initState
()
{
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Scaffold
(
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
"ShareMusicPage"
),
title:
const
Text
(
'ShareMusicPage'
),
actions:
<
Widget
>[
IconButton
(
icon:
Icon
(
Icons
.
share
,
color:
Colors
.
white
,
icon:
Icon
(
Icons
.
share
,
color:
Colors
.
white
),
onPressed:
_share
,
),
onPressed:
_share
)
],
),
body:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
new
Column
(
child:
Column
(
children:
<
Widget
>[
new
TextField
(
TextField
(
controller:
TextEditingController
(
text:
"http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3"
),
text:
'http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/'
'0042515_05.ANDY.mp3'
,
),
onChanged:
(
str
)
{
_musicUrl
=
str
;
},
decoration:
InputDecoration
(
labelText:
"music url"
),
decoration:
InputDecoration
(
labelText:
'music url'
),
),
new
TextField
(
controller:
TextEditingController
(
text:
"http://www.qq.com"
),
TextField
(
controller:
TextEditingController
(
text:
'http://www.qq.com'
),
onChanged:
(
str
)
{
_musicLowBandUrl
=
str
;
},
decoration:
InputDecoration
(
labelText:
"music low band url"
),
decoration:
InputDecoration
(
labelText:
'music low band url'
),
),
new
TextField
(
controller:
TextEditingController
(
text:
"Beyond"
),
TextField
(
controller:
TextEditingController
(
text:
'Beyond'
),
onChanged:
(
str
)
{
_title
=
str
;
},
decoration:
InputDecoration
(
labelText:
"title"
),
decoration:
InputDecoration
(
labelText:
'title'
),
),
TextField
(
controller:
TextEditingController
(
text:
'A Popular Rock Band From China'
,
),
new
TextField
(
controller:
TextEditingController
(
text:
"A Popular Rock Band From China"
),
onChanged:
(
str
)
{
_description
=
str
;
},
decoration:
InputDecoration
(
labelText:
"description"
),
decoration:
InputDecoration
(
labelText:
'description'
),
),
new
TextField
(
controller:
TextEditingController
(
text:
"images/logo.png"
),
TextField
(
controller:
TextEditingController
(
text:
'images/logo.png'
),
onChanged:
(
str
)
{
_thumnail
=
str
;
},
decoration:
InputDecoration
(
labelText:
"thumbnail"
),
decoration:
InputDecoration
(
labelText:
'thumbnail'
),
),
new
Row
(
Row
(
children:
<
Widget
>[
const
Text
(
"分享至"
),
const
Text
(
'分享至'
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
SESSION
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"会话"
)
},
),
const
Text
(
'会话'
)
],
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
TIMELINE
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"朋友圈"
)
},
),
const
Text
(
'朋友圈'
)
],
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
FAVORITE
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"收藏"
)
},
),
const
Text
(
'收藏'
)
],
)
)
,
],
)
)
,
],
),
),
...
...
@@ -127,7 +127,8 @@ class _ShareMusicPageState extends State<ShareMusicPage> {
musicUrl:
_musicUrl
,
scene:
scene
,
musicLowBandUrl:
_musicLowBandUrl
,
thumbnail:
WeChatImage
.
network
(
_thumnail
));
thumbnail:
WeChatImage
.
network
(
_thumnail
),
);
shareToWeChat
(
model
);
}
...
...
example/lib/
share_text
.dart
→
example/lib/
pages/share_text_page
.dart
浏览文件 @
71564dad
...
...
@@ -7,77 +7,73 @@ class ShareTextPage extends StatefulWidget {
}
class
_ShareTextPageState
extends
State
<
ShareTextPage
>
{
String
_text
=
"share text from fluwx"
;
String
_text
=
'share text from fluwx'
;
WeChatScene
scene
=
WeChatScene
.
SESSION
;
@override
void
initState
()
{
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Scaffold
(
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
"ShareText"
),
title:
const
Text
(
'ShareText'
),
actions:
<
Widget
>[
IconButton
(
icon:
Icon
(
Icons
.
share
,
color:
Colors
.
white
,
icon:
Icon
(
Icons
.
share
,
color:
Colors
.
white
),
onPressed:
_shareText
,
),
onPressed:
_shareText
)
],
),
body:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
new
Column
(
child:
Column
(
children:
<
Widget
>[
new
TextField
(
controller:
TextEditingController
(
text:
"share text from fluwx"
),
TextField
(
controller:
TextEditingController
(
text:
'share text from fluwx'
),
onChanged:
(
str
)
{
_text
=
str
;
},
decoration:
InputDecoration
(
labelText:
"TextToShare"
),
decoration:
InputDecoration
(
labelText:
'TextToShare'
),
),
new
Row
(
Row
(
children:
<
Widget
>[
const
Text
(
"分享至"
),
const
Text
(
'分享至'
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
SESSION
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"会话"
)
},
),
const
Text
(
'会话'
)
],
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
TIMELINE
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"朋友圈"
)
},
),
const
Text
(
'朋友圈'
)
],
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
FAVORITE
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"收藏"
)
},
),
const
Text
(
'收藏'
)
],
)
)
,
],
)
)
,
],
),
),
...
...
@@ -86,10 +82,8 @@ class _ShareTextPageState extends State<ShareTextPage> {
void
_shareText
()
{
shareToWeChat
(
WeChatShareTextModel
(
_text
,
scene:
scene
)).
then
((
data
)
{
print
(
"-->
$data
"
);
print
(
'-->
$data
'
);
});
// sendAuth(WeChatSendAuthModel(scope: "snsapi_userinfo",state: "wechat_sdk_demo_test"));
}
void
handleRadioValueChanged
(
WeChatScene
scene
)
{
...
...
example/lib/share_video_page.dart
→
example/lib/
pages/
share_video_page.dart
浏览文件 @
71564dad
...
...
@@ -2,117 +2,116 @@ import 'package:flutter/material.dart';
import
'package:fluwx/fluwx.dart'
;
class
ShareVideoPage
extends
StatefulWidget
{
const
ShareVideoPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
_ShareMusicPageState
createState
()
=>
_ShareMusicPageState
();
}
class
_ShareMusicPageState
extends
State
<
ShareVideoPage
>
{
String
_videoUrl
=
"http://www.qq.com"
;
String
_videoLowBandUrl
=
"http://www.qq.com"
;
String
_title
=
"Beyond"
;
String
_description
=
"A Popular Rock Band From China"
;
String
_thumnail
=
"images/logo.png"
;
String
_videoUrl
=
'http://www.qq.com'
;
String
_videoLowBandUrl
=
'http://www.qq.com'
;
String
_title
=
'Beyond'
;
String
_description
=
'A Popular Rock Band From China'
;
String
_thumnail
=
'images/logo.png'
;
WeChatScene
scene
=
WeChatScene
.
SESSION
;
@override
void
initState
()
{
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Scaffold
(
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
"ShareVideoPage"
),
title:
const
Text
(
'ShareVideoPage'
),
actions:
<
Widget
>[
IconButton
(
icon:
Icon
(
Icons
.
share
,
color:
Colors
.
white
,
icon:
Icon
(
Icons
.
share
,
color:
Colors
.
white
),
onPressed:
_share
,
),
onPressed:
_share
)
],
),
body:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
new
Column
(
child:
Column
(
children:
<
Widget
>[
new
TextField
(
TextField
(
controller:
TextEditingController
(
text:
"http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3"
),
text:
'http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/'
'0042515_05.ANDY.mp3'
,
),
onChanged:
(
str
)
{
_videoUrl
=
str
;
},
decoration:
InputDecoration
(
labelText:
"video url"
),
decoration:
InputDecoration
(
labelText:
'video url'
),
),
new
TextField
(
controller:
TextEditingController
(
text:
"http://www.qq.com"
),
TextField
(
controller:
TextEditingController
(
text:
'http://www.qq.com'
),
onChanged:
(
str
)
{
_videoLowBandUrl
=
str
;
},
decoration:
InputDecoration
(
labelText:
"video low band url"
),
decoration:
InputDecoration
(
labelText:
'video low band url'
),
),
new
TextField
(
controller:
TextEditingController
(
text:
"Beyond"
),
TextField
(
controller:
TextEditingController
(
text:
'Beyond'
),
onChanged:
(
str
)
{
_title
=
str
;
},
decoration:
InputDecoration
(
labelText:
"title"
),
decoration:
InputDecoration
(
labelText:
'title'
),
),
new
TextField
(
TextField
(
controller:
TextEditingController
(
text:
"A Popular Rock Band From China"
),
TextEditingController
(
text:
'A Popular Rock Band From China'
),
onChanged:
(
str
)
{
_description
=
str
;
},
decoration:
InputDecoration
(
labelText:
"description"
),
decoration:
InputDecoration
(
labelText:
'description'
),
),
new
TextField
(
controller:
TextEditingController
(
text:
"images/logo.png"
),
TextField
(
controller:
TextEditingController
(
text:
'images/logo.png'
),
onChanged:
(
str
)
{
_thumnail
=
str
;
},
decoration:
InputDecoration
(
labelText:
"thumbnail"
),
decoration:
InputDecoration
(
labelText:
'thumbnail'
),
),
new
Row
(
Row
(
children:
<
Widget
>[
const
Text
(
"分享至"
),
const
Text
(
'分享至'
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
SESSION
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"会话"
)
},
),
const
Text
(
'会话'
)
],
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
TIMELINE
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"朋友圈"
)
},
),
const
Text
(
'朋友圈'
)
],
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
FAVORITE
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"收藏"
)
},
),
const
Text
(
'收藏'
)
],
)
)
,
],
)
)
,
],
),
),
...
...
@@ -120,13 +119,14 @@ class _ShareMusicPageState extends State<ShareVideoPage> {
}
void
_share
()
{
var
model
=
new
WeChatShareVideoModel
(
var
model
=
WeChatShareVideoModel
(
videoUrl:
_videoUrl
,
videoLowBandUrl:
_videoLowBandUrl
,
thumbnail:
WeChatImage
.
network
(
_thumnail
),
description:
_description
,
scene:
this
.
scene
,
title:
_title
);
title:
_title
,
);
shareToWeChat
(
model
);
}
...
...
example/lib/share_web_page.dart
→
example/lib/
pages/
share_web_page.dart
浏览文件 @
71564dad
...
...
@@ -2,97 +2,94 @@ import 'package:flutter/material.dart';
import
'package:fluwx/fluwx.dart'
;
class
ShareWebPagePage
extends
StatefulWidget
{
const
ShareWebPagePage
({
Key
?
key
})
:
super
(
key:
key
);
@override
ShareWebPagePageState
createState
()
{
return
new
ShareWebPagePageState
();
}
ShareWebPagePageState
createState
()
=>
ShareWebPagePageState
();
}
class
ShareWebPagePageState
extends
State
<
ShareWebPagePage
>
{
String
_url
=
"share text from fluwx"
;
String
_title
=
"Fluwx"
;
String
_thumnail
=
"images/logo.png"
;
String
_url
=
'share text from fluwx'
;
String
_title
=
'Fluwx'
;
String
_thumnail
=
'images/logo.png'
;
WeChatScene
scene
=
WeChatScene
.
SESSION
;
@override
void
initState
()
{
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Scaffold
(
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
"ShareWebPage"
),
title:
const
Text
(
'ShareWebPage'
),
actions:
<
Widget
>[
IconButton
(
icon:
Icon
(
Icons
.
share
,
color:
Colors
.
white
,
icon:
Icon
(
Icons
.
share
,
color:
Colors
.
white
),
onPressed:
_share
,
),
onPressed:
_share
)
],
),
body:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
new
Column
(
child:
Column
(
children:
<
Widget
>[
new
TextField
(
TextField
(
controller:
TextEditingController
(
text:
"https://github.com/JarvanMo/fluwx"
),
text:
'https://github.com/JarvanMo/fluwx'
,
),
onChanged:
(
str
)
{
_url
=
str
;
},
decoration:
InputDecoration
(
labelText:
"web page"
),
decoration:
InputDecoration
(
labelText:
'web page'
),
),
new
TextField
(
controller:
TextEditingController
(
text:
"Fluwx"
),
TextField
(
controller:
TextEditingController
(
text:
'Fluwx'
),
onChanged:
(
str
)
{
_title
=
str
;
},
decoration:
InputDecoration
(
labelText:
"thumbnail"
),
decoration:
InputDecoration
(
labelText:
'thumbnail'
),
),
new
TextField
(
controller:
TextEditingController
(
text:
"images/logo.png"
),
TextField
(
controller:
TextEditingController
(
text:
'images/logo.png'
),
onChanged:
(
str
)
{
_thumnail
=
str
;
},
decoration:
InputDecoration
(
labelText:
"thumbnail"
),
decoration:
InputDecoration
(
labelText:
'thumbnail'
),
),
new
Row
(
Row
(
children:
<
Widget
>[
const
Text
(
"分享至"
),
const
Text
(
'分享至'
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
SESSION
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"会话"
)
},
),
const
Text
(
'会话'
)
],
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
TIMELINE
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"朋友圈"
)
},
),
const
Text
(
'朋友圈'
)
],
),
Row
(
children:
<
Widget
>[
new
Radio
<
WeChatScene
>(
Radio
<
WeChatScene
>(
value:
WeChatScene
.
FAVORITE
,
groupValue:
scene
,
onChanged:
(
v
)
{
if
(
v
!=
null
)
handleRadioValueChanged
(
v
);
}),
const
Text
(
"收藏"
)
},
),
const
Text
(
'收藏'
)
],
)
],
...
...
example/lib/sign_auto_deduct_page.dart
→
example/lib/
pages/
sign_auto_deduct_page.dart
浏览文件 @
71564dad
...
...
@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
import
'package:fluwx/fluwx.dart'
;
class
SignAutoDeductPage
extends
StatefulWidget
{
const
SignAutoDeductPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
_SignAutoDeductPageState
createState
()
=>
_SignAutoDeductPageState
();
}
...
...
@@ -10,24 +12,24 @@ class SignAutoDeductPage extends StatefulWidget {
/// see wechat [document](https://pay.weixin.qq.com/wiki/doc/api/pap.php?chapter=18_5&index=2)
class
_SignAutoDeductPageState
extends
State
<
SignAutoDeductPage
>
{
TextEditingController
appId
=
TextEditingController
(
text:
"wx316f9c82e99ac105"
);
TextEditingController
mchId
=
TextEditingController
(
text:
""
);
TextEditingController
planId
=
TextEditingController
(
text:
""
);
TextEditingController
contractCode
=
TextEditingController
(
text:
""
);
TextEditingController
requestSerial
=
TextEditingController
(
text:
""
);
TextEditingController
(
text:
'wx316f9c82e99ac105'
);
TextEditingController
mchId
=
TextEditingController
(
text:
''
);
TextEditingController
planId
=
TextEditingController
(
text:
''
);
TextEditingController
contractCode
=
TextEditingController
(
text:
''
);
TextEditingController
requestSerial
=
TextEditingController
(
text:
''
);
TextEditingController
contractDisplayAccount
=
TextEditingController
(
text:
""
);
TextEditingController
notifyUrl
=
TextEditingController
(
text:
""
);
TextEditingController
version
=
TextEditingController
(
text:
"1.0"
);
TextEditingController
sign
=
TextEditingController
(
text:
""
);
TextEditingController
timestamp
=
TextEditingController
(
text:
""
);
TextEditingController
returnApp
=
TextEditingController
(
text:
"3"
);
TextEditingController
(
text:
''
);
TextEditingController
notifyUrl
=
TextEditingController
(
text:
''
);
TextEditingController
version
=
TextEditingController
(
text:
'1.0'
);
TextEditingController
sign
=
TextEditingController
(
text:
''
);
TextEditingController
timestamp
=
TextEditingController
(
text:
''
);
TextEditingController
returnApp
=
TextEditingController
(
text:
'3'
);
@override
void
initState
()
{
super
.
initState
();
weChatResponseEventHandler
.
listen
((
resp
)
{
print
(
"resp =
${resp.isSuccessful}
"
);
print
(
'resp =
${resp.isSuccessful}
'
);
});
}
...
...
@@ -57,21 +59,50 @@ class _SignAutoDeductPageState extends State<SignAutoDeductPage> {
body:
Container
(
child:
ListView
(
children:
<
Widget
>[
_buildTextField
(
title:
"appId"
,
textEditController:
appId
),
_buildTextField
(
title:
"mchId"
,
textEditController:
mchId
),
_buildTextField
(
title:
"planId"
,
textEditController:
planId
),
_buildTextField
(
title:
"contractCode"
,
textEditController:
contractCode
),
title:
'appId'
,
textEditController:
appId
,
),
_buildTextField
(
title:
'mchId'
,
textEditController:
mchId
,
),
_buildTextField
(
title:
'planId'
,
textEditController:
planId
,
),
_buildTextField
(
title:
'contractCode'
,
textEditController:
contractCode
,
),
_buildTextField
(
title:
'requestSerial'
,
textEditController:
requestSerial
,
),
_buildTextField
(
title:
'contractDisplayAccount'
,
textEditController:
contractDisplayAccount
,
),
_buildTextField
(
title:
'notifyUrl'
,
textEditController:
notifyUrl
,
),
_buildTextField
(
title:
"requestSerial"
,
textEditController:
requestSerial
),
title:
'version'
,
textEditController:
version
,
),
_buildTextField
(
title:
'sign'
,
textEditController:
sign
,
),
_buildTextField
(
title:
"contractDisplayAccount"
,
textEditController:
contractDisplayAccount
)
,
_buildTextField
(
title:
"notifyUrl"
,
textEditController:
notifyUrl
),
_buildTextField
(
title:
"version"
,
textEditController:
version
),
_buildTextField
(
title:
"sign"
,
textEditController:
sign
)
,
_buildTextField
(
title:
"timestamp"
,
textEditController:
timestamp
)
,
_buildTextField
(
title:
"returnApp"
,
textEditController:
returnApp
),
title:
'timestamp'
,
textEditController:
timestamp
,
),
_buildTextField
(
title:
'returnApp'
,
textEditController:
returnApp
,
),
CupertinoButton
(
child:
Text
(
'request once sign auto-deduct message'
),
onPressed:
_signAutoDeduct
,
...
...
@@ -87,18 +118,16 @@ class _SignAutoDeductPageState extends State<SignAutoDeductPage> {
TextEditingController
?
textEditController
,
})
{
return
TextField
(
decoration:
InputDecoration
(
labelText:
title
,
),
decoration:
InputDecoration
(
labelText:
title
),
controller:
textEditController
,
);
}
void
_signAutoDeduct
()
{
autoDeDuctWeChat
(
appId:
appId
.
text
,
appId:
appId
.
text
,
mchId:
mchId
.
text
,
planId:
planId
.
text
,
planId:
planId
.
text
,
contractCode:
contractCode
.
text
,
requestSerial:
requestSerial
.
text
,
contractDisplayAccount:
contractDisplayAccount
.
text
,
...
...
@@ -106,6 +135,7 @@ class _SignAutoDeductPageState extends State<SignAutoDeductPage> {
version:
version
.
text
,
sign:
sign
.
text
,
timestamp:
timestamp
.
text
,
returnApp:
'3'
);
returnApp:
'3'
,
);
}
}
example/lib/subscribe_message_page.dart
→
example/lib/
pages/
subscribe_message_page.dart
浏览文件 @
71564dad
...
...
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
import
'package:fluwx/fluwx.dart'
;
class
SubscribeMessagePage
extends
StatefulWidget
{
const
SubscribeMessagePage
({
Key
?
key
})
:
super
(
key:
key
);
@override
_SubscribeMessagePageState
createState
()
=>
_SubscribeMessagePageState
();
}
...
...
@@ -9,17 +11,17 @@ class SubscribeMessagePage extends StatefulWidget {
/// see wechat [document](https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500434436_aWfqW&token=&lang=zh_CN)
class
_SubscribeMessagePageState
extends
State
<
SubscribeMessagePage
>
{
TextEditingController
appId
=
TextEditingController
(
text:
"wx316f9c82e99ac105"
);
TextEditingController
scene
=
TextEditingController
(
text:
"1"
);
TextEditingController
(
text:
'wx316f9c82e99ac105'
);
TextEditingController
scene
=
TextEditingController
(
text:
'1'
);
TextEditingController
templateId
=
TextEditingController
(
text:
"cm_vM2k3IjHcYbkGUeAfL6Fja_7Pgv4Hx_q4tA253Ss"
);
TextEditingController
reserved
=
TextEditingController
(
text:
"123"
);
text:
'cm_vM2k3IjHcYbkGUeAfL6Fja_7Pgv4Hx_q4tA253Ss'
);
TextEditingController
reserved
=
TextEditingController
(
text:
'123'
);
@override
void
initState
()
{
super
.
initState
();
weChatResponseEventHandler
.
listen
((
resp
)
{
print
(
"resp =
$resp
"
);
print
(
'resp =
$resp
'
);
});
}
...
...
@@ -41,12 +43,23 @@ class _SubscribeMessagePageState extends State<SubscribeMessagePage> {
body:
Container
(
child:
Column
(
children:
<
Widget
>[
_buildTextField
(
title:
"appId"
,
textEditController:
appId
),
_buildTextField
(
title:
"scene"
,
textEditController:
scene
),
_buildTextField
(
title:
"templateId"
,
textEditController:
templateId
),
_buildTextField
(
title:
"reserved"
,
textEditController:
reserved
),
FlatButton
(
title:
'appId'
,
textEditController:
appId
,
),
_buildTextField
(
title:
'scene'
,
textEditController:
scene
,
),
_buildTextField
(
title:
'templateId'
,
textEditController:
templateId
,
),
_buildTextField
(
title:
'reserved'
,
textEditController:
reserved
,
),
TextButton
(
child:
Text
(
'request once subscribe message'
),
onPressed:
_requestSubMsg
,
),
...
...
@@ -61,9 +74,7 @@ class _SubscribeMessagePageState extends State<SubscribeMessagePage> {
TextEditingController
?
textEditController
,
})
{
return
TextField
(
decoration:
InputDecoration
(
labelText:
title
,
),
decoration:
InputDecoration
(
labelText:
title
),
controller:
textEditController
,
);
}
...
...
example/test/widget_test.dart
浏览文件 @
71564dad
...
...
@@ -5,7 +5,6 @@
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:fluwx_example/main.dart'
;
...
...
lib/fluwx.dart
浏览文件 @
71564dad
...
...
@@ -4,8 +4,8 @@
/// A open sou;rce project authorized by [OpenFlutter](https://github.com/OpenFlutter).
library
fluwx
;
export
'
package:fluwx/
src/fluwx_iml.dart'
;
export
'
package:fluwx/
src/response/wechat_response.dart'
;
export
'
package:fluwx/
src/share/share_models.dart'
;
export
'
package:fluwx/
src/wechat_enums.dart'
;
export
'
package:fluwx/
src/wechat_file.dart'
hide
FileSchema
;
export
'src/fluwx_iml.dart'
;
export
'src/response/wechat_response.dart'
;
export
'src/share/share_models.dart'
;
export
'src/wechat_enums.dart'
;
export
'src/wechat_file.dart'
hide
FileSchema
;
lib/src/fluwx_iml.dart
浏览文件 @
71564dad
差异被折叠。
点击展开。
lib/src/response/wechat_response.dart
浏览文件 @
71564dad
...
...
@@ -19,42 +19,37 @@
import
'dart:typed_data'
;
const
String
_errCode
=
"errCode"
;
const
String
_errStr
=
"errStr"
;
const
String
_errCode
=
'errCode'
;
const
String
_errStr
=
'errStr'
;
typedef
BaseWeChatResponse
_WeChatResponseInvoker
(
Map
argument
);
Map
<
String
,
_WeChatResponseInvoker
>
_nameAndResponseMapper
=
{
"onShareResponse"
:
(
Map
argument
)
=>
WeChatShareResponse
.
fromMap
(
argument
),
"onAuthResponse"
:
(
Map
argument
)
=>
WeChatAuthResponse
.
fromMap
(
argument
),
"onLaunchMiniProgramResponse"
:
(
Map
argument
)
=>
'onShareResponse'
:
(
Map
argument
)
=>
WeChatShareResponse
.
fromMap
(
argument
),
'onAuthResponse'
:
(
Map
argument
)
=>
WeChatAuthResponse
.
fromMap
(
argument
),
'onLaunchMiniProgramResponse'
:
(
Map
argument
)
=>
WeChatLaunchMiniProgramResponse
.
fromMap
(
argument
),
"onPayResponse"
:
(
Map
argument
)
=>
WeChatPaymentResponse
.
fromMap
(
argument
),
"onSubscribeMsgResp"
:
(
Map
argument
)
=>
'onPayResponse'
:
(
Map
argument
)
=>
WeChatPaymentResponse
.
fromMap
(
argument
),
'onSubscribeMsgResp'
:
(
Map
argument
)
=>
WeChatSubscribeMsgResponse
.
fromMap
(
argument
),
"onWXOpenBusinessWebviewResponse"
:
(
Map
argument
)
=>
'onWXOpenBusinessWebviewResponse'
:
(
Map
argument
)
=>
WeChatOpenBusinessWebviewResponse
.
fromMap
(
argument
),
"onAuthByQRCodeFinished"
:
(
Map
argument
)
=>
'onAuthByQRCodeFinished'
:
(
Map
argument
)
=>
WeChatAuthByQRCodeFinishedResponse
.
fromMap
(
argument
),
"onAuthGotQRCode"
:
(
Map
argument
)
=>
'onAuthGotQRCode'
:
(
Map
argument
)
=>
WeChatAuthGotQRCodeResponse
.
fromMap
(
argument
),
"onQRCodeScanned"
:
(
Map
argument
)
=>
'onQRCodeScanned'
:
(
Map
argument
)
=>
WeChatQRCodeScannedResponse
.
fromMap
(
argument
),
"onWXShowMessageFromWX"
:
(
Map
argument
)
=>
'onWXShowMessageFromWX'
:
(
Map
argument
)
=>
WeChatShowMessageFromWXRequest
.
fromMap
(
argument
),
"onWXOpenCustomerServiceChatResponse"
:
(
Map
argument
)
=>
'onWXOpenCustomerServiceChatResponse'
:
(
Map
argument
)
=>
WeChatOpenCustomerServiceChatResponse
.
fromMap
(
argument
),
};
class
BaseWeChatResponse
{
final
int
errCode
;
final
String
?
errStr
;
bool
get
isSuccessful
=>
errCode
==
0
;
BaseWeChatResponse
.
_
(
this
.
errCode
,
this
.
errStr
);
///
create response from response pool
///
Create response from the response pool.
factory
BaseWeChatResponse
.
create
(
String
name
,
Map
argument
)
{
var
result
=
_nameAndResponseMapper
[
name
];
if
(
result
==
null
)
{
...
...
@@ -62,127 +57,129 @@ class BaseWeChatResponse {
}
return
result
(
argument
);
}
final
int
errCode
;
final
String
?
errStr
;
bool
get
isSuccessful
=>
errCode
==
0
;
}
class
WeChatShareResponse
extends
BaseWeChatResponse
{
final
int
type
;
WeChatShareResponse
.
fromMap
(
Map
map
)
:
type
=
map
[
"type"
],
:
type
=
map
[
'type'
],
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
final
int
type
;
}
class
WeChatAuthResponse
extends
BaseWeChatResponse
{
WeChatAuthResponse
.
fromMap
(
Map
map
)
:
type
=
map
[
'type'
],
country
=
map
[
'country'
],
lang
=
map
[
'lang'
],
code
=
map
[
'code'
],
state
=
map
[
'state'
],
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
final
int
type
;
final
String
?
country
;
final
String
?
lang
;
final
String
?
code
;
final
String
?
state
;
WeChatAuthResponse
.
fromMap
(
Map
map
)
:
type
=
map
[
"type"
],
country
=
map
[
"country"
],
lang
=
map
[
"lang"
],
code
=
map
[
"code"
],
state
=
map
[
"state"
],
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
@override
bool
operator
==(
other
)
{
if
(
other
is
WeChatAuthResponse
)
{
return
code
==
other
.
code
&&
return
other
is
WeChatAuthResponse
&&
code
==
other
.
code
&&
country
==
other
.
country
&&
lang
==
other
.
lang
&&
state
==
other
.
state
;
}
else
{
return
false
;
}
}
@override
int
get
hashCode
=>
super
.
hashCode
+
errCode
.
hashCode
&
1345
+
errStr
.
hashCode
&
15
+
(
code
??
""
).
hashCode
&
15
+
(
code
??
''
).
hashCode
&
1432
;
}
class
WeChatLaunchMiniProgramResponse
extends
BaseWeChatResponse
{
final
int
?
type
;
final
String
?
extMsg
;
WeChatLaunchMiniProgramResponse
.
fromMap
(
Map
map
)
:
type
=
map
[
"type"
],
extMsg
=
map
[
"extMsg"
],
:
type
=
map
[
'type'
],
extMsg
=
map
[
'extMsg'
],
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
final
int
?
type
;
final
String
?
extMsg
;
}
class
WeChatPaymentResponse
extends
BaseWeChatResponse
{
final
int
type
;
final
String
?
extData
;
WeChatPaymentResponse
.
fromMap
(
Map
map
)
:
type
=
map
[
"type"
],
extData
=
map
[
"extData"
],
:
type
=
map
[
'type'
],
extData
=
map
[
'extData'
],
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
final
int
type
;
final
String
?
extData
;
}
class
WeChatOpenCustomerServiceChatResponse
extends
BaseWeChatResponse
{
final
String
?
extMsg
;
WeChatOpenCustomerServiceChatResponse
.
fromMap
(
Map
map
)
:
extMsg
=
map
[
"extMsg"
],
:
extMsg
=
map
[
'extMsg'
],
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
final
String
?
extMsg
;
}
class
WeChatSubscribeMsgResponse
extends
BaseWeChatResponse
{
WeChatSubscribeMsgResponse
.
fromMap
(
Map
map
)
:
openid
=
map
[
'openid'
],
templateId
=
map
[
'templateId'
],
action
=
map
[
'action'
],
reserved
=
map
[
'reserved'
],
scene
=
map
[
'scene'
],
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
final
String
?
openid
;
final
String
?
templateId
;
final
String
?
action
;
final
String
?
reserved
;
final
int
scene
;
WeChatSubscribeMsgResponse
.
fromMap
(
Map
map
)
:
openid
=
map
[
"openid"
],
templateId
=
map
[
"templateId"
],
action
=
map
[
"action"
],
reserved
=
map
[
"reserved"
],
scene
=
map
[
"scene"
],
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
}
class
WeChatOpenBusinessWebviewResponse
extends
BaseWeChatResponse
{
WeChatOpenBusinessWebviewResponse
.
fromMap
(
Map
map
)
:
type
=
map
[
'type'
],
errCode
=
map
[
_errCode
],
businessType
=
map
[
'businessType'
],
resultInfo
=
map
[
'resultInfo'
],
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
final
int
?
type
;
final
int
errCode
;
final
int
?
businessType
;
final
String
resultInfo
;
WeChatOpenBusinessWebviewResponse
.
fromMap
(
Map
map
)
:
type
=
map
[
"type"
],
errCode
=
map
[
_errCode
],
businessType
=
map
[
"businessType"
],
resultInfo
=
map
[
"resultInfo"
],
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
}
class
WeChatAuthByQRCodeFinishedResponse
extends
BaseWeChatResponse
{
final
String
?
authCode
;
final
AuthByQRCodeErrorCode
?
qrCodeErrorCode
;
WeChatAuthByQRCodeFinishedResponse
.
fromMap
(
Map
map
)
:
authCode
=
map
[
"authCode"
],
:
authCode
=
map
[
'authCode'
],
qrCodeErrorCode
=
(
_authByQRCodeErrorCodes
[
_errCode
]
??
AuthByQRCodeErrorCode
.
UNKNOWN
),
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
final
String
?
authCode
;
final
AuthByQRCodeErrorCode
?
qrCodeErrorCode
;
}
///[qrCode] in memory.
class
WeChatAuthGotQRCodeResponse
extends
BaseWeChatResponse
{
final
Uint8List
?
qrCode
;
WeChatAuthGotQRCodeResponse
.
fromMap
(
Map
map
)
:
qrCode
=
map
[
"qrCode"
],
:
qrCode
=
map
[
'qrCode'
],
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
final
Uint8List
?
qrCode
;
}
class
WeChatQRCodeScannedResponse
extends
BaseWeChatResponse
{
...
...
@@ -192,30 +189,21 @@ class WeChatQRCodeScannedResponse extends BaseWeChatResponse {
// 获取微信打开App时携带的参数
class
WeChatShowMessageFromWXRequest
extends
BaseWeChatResponse
{
final
String
?
extMsg
;
WeChatShowMessageFromWXRequest
.
fromMap
(
Map
map
)
:
extMsg
=
map
[
"extMsg"
],
:
extMsg
=
map
[
'extMsg'
],
super
.
_
(
0
,
''
);
final
String
?
extMsg
;
}
///WechatAuth_Err_OK(0),
///WechatAuth_Err_NormalErr(-1),
///WechatAuth_Err_NetworkErr(-2),
///WechatAuth_Err_JsonDecodeErr(-3),
///WechatAuth_Err_Cancel(-4),
///WechatAuth_Err_Timeout(-5),
///WechatAuth_Err_Auth_Stopped(-6);
///[AuthByQRCodeErrorCode.JSON_DECODE_ERR] means WechatAuth_Err_GetQrcodeFailed when platform is iOS
///only Android will get [AUTH_STOPPED]
enum
AuthByQRCodeErrorCode
{
OK
,
NORMAL_ERR
,
NETWORK_ERR
,
JSON_DECODE_ERR
,
CANCEL
,
TIMEOUT
,
AUTH_STOPPED
,
OK
,
// WechatAuth_Err_OK(0)
NORMAL_ERR
,
// WechatAuth_Err_NormalErr(-1)
NETWORK_ERR
,
// WechatAuth_Err_NetworkErr(-2)
JSON_DECODE_ERR
,
// WechatAuth_Err_JsonDecodeErr(-3), WechatAuth_Err_GetQrcodeFailed on iOS
CANCEL
,
// WechatAuth_Err_Cancel(-4)
TIMEOUT
,
// WechatAuth_Err_Timeout(-5)
AUTH_STOPPED
,
// WechatAuth_Err_Auth_Stopped(-6), Android only
UNKNOWN
}
...
...
lib/src/share/share_models.dart
浏览文件 @
71564dad
...
...
@@ -16,9 +16,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
import
'package:flutter/foundation.dart'
;
import
'package:fluwx/fluwx.dart'
;
import
'package:fluwx/src/wechat_enums.dart'
;
const
String
_scene
=
"scene"
;
const
String
_source
=
"source"
;
...
...
@@ -34,9 +32,20 @@ mixin WeChatShareBaseModel {
Map
toMap
();
}
///[source] the text you want to send to WeChat
///[scene] the target you want to send
///
[source] the text you want to send to WeChat
///
[scene] the target you want to send
class
WeChatShareTextModel
implements
WeChatShareBaseModel
{
WeChatShareTextModel
(
this
.
source
,
{
this
.
scene
=
WeChatScene
.
SESSION
,
this
.
mediaTagName
,
this
.
messageAction
,
this
.
messageExt
,
String
?
description
,
String
?
title
,
})
:
this
.
title
=
title
??
source
,
this
.
description
=
description
??
source
;
final
String
source
;
final
WeChatScene
scene
;
final
String
?
messageExt
;
...
...
@@ -45,16 +54,6 @@ class WeChatShareTextModel implements WeChatShareBaseModel {
final
String
?
title
;
final
String
?
description
;
WeChatShareTextModel
(
this
.
source
,
{
this
.
scene
=
WeChatScene
.
SESSION
,
this
.
mediaTagName
,
this
.
messageAction
,
this
.
messageExt
,
String
?
description
,
String
?
title
})
:
this
.
title
=
title
??
source
,
this
.
description
=
description
??
source
;
@override
Map
toMap
()
{
return
{
...
...
@@ -69,26 +68,12 @@ class WeChatShareTextModel implements WeChatShareBaseModel {
}
}
///
/// the default value is [MINI_PROGRAM_TYPE_RELEASE]
///[hdImagePath] only works on iOS, not sure the relationship between [thumbnail] and [hdImagePath].
/// [hdImagePath] only works on iOS, not sure the relationship
/// between [thumbnail] and [hdImagePath].
class
WeChatShareMiniProgramModel
implements
WeChatShareBaseModel
{
final
String
webPageUrl
;
final
WXMiniProgramType
miniProgramType
;
final
String
userName
;
final
String
path
;
final
WeChatImage
?
hdImagePath
;
final
String
?
title
;
final
String
?
description
;
final
WeChatImage
?
thumbnail
;
final
bool
withShareTicket
;
final
String
?
messageExt
;
final
String
?
messageAction
;
final
String
?
mediaTagName
;
final
bool
compressThumbnail
;
WeChatShareMiniProgramModel
(
{
required
this
.
webPageUrl
,
WeChatShareMiniProgramModel
({
required
this
.
webPageUrl
,
this
.
miniProgramType
=
WXMiniProgramType
.
RELEASE
,
required
this
.
userName
,
this
.
path
:
"/"
,
...
...
@@ -100,11 +85,25 @@ class WeChatShareMiniProgramModel implements WeChatShareBaseModel {
this
.
mediaTagName
,
this
.
messageAction
,
this
.
messageExt
,
this
.
compressThumbnail
=
true
})
:
assert
(
webPageUrl
.
isNotEmpty
),
this
.
compressThumbnail
=
true
,
})
:
assert
(
webPageUrl
.
isNotEmpty
),
assert
(
userName
.
isNotEmpty
),
assert
(
path
.
isNotEmpty
);
final
String
webPageUrl
;
final
WXMiniProgramType
miniProgramType
;
final
String
userName
;
final
String
path
;
final
WeChatImage
?
hdImagePath
;
final
String
?
title
;
final
String
?
description
;
final
WeChatImage
?
thumbnail
;
final
bool
withShareTicket
;
final
String
?
messageExt
;
final
String
?
messageAction
;
final
String
?
mediaTagName
;
final
bool
compressThumbnail
;
@override
Map
toMap
()
{
return
{
...
...
@@ -124,10 +123,22 @@ class WeChatShareMiniProgramModel implements WeChatShareBaseModel {
}
}
///[source] the image you want to send to WeChat
///[scene] the target you want to send
///[thumbnail] the preview of your image, will be created from [scene] if null.
///
[source] the image you want to send to WeChat
///
[scene] the target you want to send
///
[thumbnail] the preview of your image, will be created from [scene] if null.
class
WeChatShareImageModel
implements
WeChatShareBaseModel
{
WeChatShareImageModel
(
this
.
source
,
{
WeChatImage
?
thumbnail
,
this
.
title
,
this
.
scene
=
WeChatScene
.
SESSION
,
this
.
description
,
this
.
mediaTagName
,
this
.
messageAction
,
this
.
messageExt
,
this
.
compressThumbnail
=
true
,
})
:
this
.
thumbnail
=
thumbnail
??
source
;
final
WeChatImage
source
;
final
WeChatImage
thumbnail
;
final
String
?
title
;
...
...
@@ -138,17 +149,6 @@ class WeChatShareImageModel implements WeChatShareBaseModel {
final
String
?
mediaTagName
;
final
bool
compressThumbnail
;
WeChatShareImageModel
(
this
.
source
,
{
WeChatImage
?
thumbnail
,
this
.
title
,
this
.
scene
=
WeChatScene
.
SESSION
,
this
.
description
,
this
.
mediaTagName
,
this
.
messageAction
,
this
.
messageExt
,
this
.
compressThumbnail
=
true
})
:
this
.
thumbnail
=
thumbnail
??
source
;
@override
Map
toMap
()
{
return
{
...
...
@@ -167,6 +167,21 @@ class WeChatShareImageModel implements WeChatShareBaseModel {
/// if [musicUrl] and [musicLowBandUrl] are both provided,
/// only [musicUrl] will be used.
class
WeChatShareMusicModel
implements
WeChatShareBaseModel
{
WeChatShareMusicModel
({
this
.
musicUrl
,
this
.
musicLowBandUrl
,
this
.
title
:
""
,
this
.
description
:
""
,
this
.
musicDataUrl
,
this
.
musicLowBandDataUrl
,
this
.
thumbnail
,
this
.
mediaTagName
,
this
.
messageAction
,
this
.
messageExt
,
this
.
scene
=
WeChatScene
.
SESSION
,
this
.
compressThumbnail
=
true
,
})
:
assert
(
musicUrl
!=
null
||
musicLowBandUrl
!=
null
);
final
String
?
musicUrl
;
final
String
?
musicDataUrl
;
final
String
?
musicLowBandUrl
;
...
...
@@ -180,21 +195,6 @@ class WeChatShareMusicModel implements WeChatShareBaseModel {
final
String
?
mediaTagName
;
final
bool
compressThumbnail
;
WeChatShareMusicModel
(
{
this
.
musicUrl
,
this
.
musicLowBandUrl
,
this
.
title
:
""
,
this
.
description
:
""
,
this
.
musicDataUrl
,
this
.
musicLowBandDataUrl
,
this
.
thumbnail
,
this
.
mediaTagName
,
this
.
messageAction
,
this
.
messageExt
,
this
.
scene
=
WeChatScene
.
SESSION
,
this
.
compressThumbnail
=
true
})
:
assert
(
musicUrl
!=
null
||
musicLowBandUrl
!=
null
);
@override
Map
toMap
()
{
return
{
...
...
@@ -216,6 +216,20 @@ class WeChatShareMusicModel implements WeChatShareBaseModel {
/// if [videoUrl] and [videoLowBandUrl] are both provided,
/// only [videoUrl] will be used.
class
WeChatShareVideoModel
implements
WeChatShareBaseModel
{
WeChatShareVideoModel
({
this
.
scene
=
WeChatScene
.
SESSION
,
this
.
videoUrl
,
this
.
videoLowBandUrl
,
this
.
title
:
""
,
this
.
description
:
""
,
this
.
thumbnail
,
this
.
mediaTagName
,
this
.
messageAction
,
this
.
messageExt
,
this
.
compressThumbnail
=
true
,
})
:
assert
(
videoUrl
!=
null
||
videoLowBandUrl
!=
null
),
assert
(
thumbnail
!=
null
);
final
String
?
videoUrl
;
final
String
?
videoLowBandUrl
;
final
WeChatImage
?
thumbnail
;
...
...
@@ -227,20 +241,6 @@ class WeChatShareVideoModel implements WeChatShareBaseModel {
final
String
?
mediaTagName
;
final
bool
compressThumbnail
;
WeChatShareVideoModel
(
{
this
.
scene
=
WeChatScene
.
SESSION
,
this
.
videoUrl
,
this
.
videoLowBandUrl
,
this
.
title
:
""
,
this
.
description
:
""
,
this
.
thumbnail
,
this
.
mediaTagName
,
this
.
messageAction
,
this
.
messageExt
,
this
.
compressThumbnail
=
true
})
:
assert
(
videoUrl
!=
null
||
videoLowBandUrl
!=
null
),
assert
(
thumbnail
!=
null
);
@override
Map
toMap
()
{
return
{
...
...
@@ -257,9 +257,22 @@ class WeChatShareVideoModel implements WeChatShareBaseModel {
}
}
///[webPage] url you want to send to wechat
///[thumbnail] logo of your website
///
[webPage] url you want to send to wechat
///
[thumbnail] logo of your website
class
WeChatShareWebPageModel
implements
WeChatShareBaseModel
{
WeChatShareWebPageModel
(
this
.
webPage
,
{
this
.
title
:
""
,
String
?
description
,
this
.
thumbnail
,
this
.
scene
=
WeChatScene
.
SESSION
,
this
.
mediaTagName
,
this
.
messageAction
,
this
.
messageExt
,
this
.
compressThumbnail
=
true
,
})
:
assert
(
webPage
.
isNotEmpty
),
this
.
description
=
description
??
webPage
;
final
String
webPage
;
final
WeChatImage
?
thumbnail
;
final
String
title
;
...
...
@@ -270,18 +283,6 @@ class WeChatShareWebPageModel implements WeChatShareBaseModel {
final
String
?
mediaTagName
;
final
bool
compressThumbnail
;
WeChatShareWebPageModel
(
this
.
webPage
,
{
this
.
title
:
""
,
String
?
description
,
this
.
thumbnail
,
this
.
scene
=
WeChatScene
.
SESSION
,
this
.
mediaTagName
,
this
.
messageAction
,
this
.
messageExt
,
this
.
compressThumbnail
=
true
})
:
assert
(
webPage
.
isNotEmpty
),
this
.
description
=
description
??
webPage
;
@override
Map
toMap
()
{
return
{
...
...
@@ -301,6 +302,18 @@ class WeChatShareWebPageModel implements WeChatShareBaseModel {
/// [scene] can't be [WeChatScene.TIMELINE], otherwise, sharing nothing.
/// send files to WeChat
class
WeChatShareFileModel
implements
WeChatShareBaseModel
{
WeChatShareFileModel
(
this
.
source
,
{
this
.
title
:
""
,
this
.
description
:
""
,
this
.
thumbnail
,
this
.
scene
=
WeChatScene
.
SESSION
,
this
.
mediaTagName
,
this
.
messageAction
,
this
.
messageExt
,
this
.
compressThumbnail
=
true
,
});
final
WeChatFile
source
;
final
WeChatImage
?
thumbnail
;
final
String
title
;
...
...
@@ -311,16 +324,6 @@ class WeChatShareFileModel implements WeChatShareBaseModel {
final
String
?
mediaTagName
;
final
bool
compressThumbnail
;
WeChatShareFileModel
(
this
.
source
,
{
this
.
title
:
""
,
this
.
description
:
""
,
this
.
thumbnail
,
this
.
scene
=
WeChatScene
.
SESSION
,
this
.
mediaTagName
,
this
.
messageAction
,
this
.
messageExt
,
this
.
compressThumbnail
=
true
});
@override
Map
toMap
()
{
return
{
...
...
lib/src/wechat_enums.dart
浏览文件 @
71564dad
...
...
@@ -17,14 +17,14 @@
* the License.
*/
///[WXMiniProgramType.RELEASE]正式版
///[WXMiniProgramType.TEST]测试版
///[WXMiniProgramType.PREVIEW]预览版
///
[WXMiniProgramType.RELEASE]正式版
///
[WXMiniProgramType.TEST]测试版
///
[WXMiniProgramType.PREVIEW]预览版
enum
WXMiniProgramType
{
RELEASE
,
TEST
,
PREVIEW
}
///[WeChatScene.SESSION]会话
///[WeChatScene.TIMELINE]朋友圈
///[WeChatScene.FAVORITE]收藏
///
[WeChatScene.SESSION]会话
///
[WeChatScene.TIMELINE]朋友圈
///
[WeChatScene.FAVORITE]收藏
enum
WeChatScene
{
SESSION
,
TIMELINE
,
FAVORITE
}
extension
MiniProgramTypeExtensions
on
WXMiniProgramType
{
...
...
@@ -36,7 +36,8 @@ extension MiniProgramTypeExtensions on WXMiniProgramType {
return
1
;
case
WXMiniProgramType
.
RELEASE
:
return
0
;
}
default
:
return
0
;
}
}
}
lib/src/wechat_file.dart
浏览文件 @
71564dad
...
...
@@ -4,14 +4,14 @@
* Licensed to the Apache Software Foundation (ASF) under one or more contributor
* license agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership. The ASF licenses this
* file to you under the Apache License, Version 2.0 (the
"License"
); you may not
* file to you under the Apache License, Version 2.0 (the
'License'
); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an
"AS IS"
BASIS, WITHOUT
* distributed under the License is distributed on an
'AS IS'
BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
...
...
@@ -19,85 +19,96 @@
import
'dart:io'
;
import
'dart:typed_data'
;
const
String
defaultSuffixJpeg
=
".jpeg"
;
const
String
defaultSuffixTxt
=
".txt"
;
const
String
defaultSuffixJpeg
=
'.jpeg'
;
const
String
defaultSuffixTxt
=
'.txt'
;
class
WeChatImage
extends
WeChatFile
{
WeChatImage
.
network
(
String
source
,
{
String
suffix
=
defaultSuffixJpeg
})
:
super
.
network
(
source
,
suffix:
suffix
);
WeChatImage
.
network
(
String
source
,
{
String
suffix
=
defaultSuffixJpeg
,
})
:
super
.
network
(
source
,
suffix:
suffix
);
WeChatImage
.
asset
(
String
source
,
{
String
suffix
=
defaultSuffixJpeg
})
:
super
.
asset
(
source
,
suffix:
suffix
);
WeChatImage
.
asset
(
String
source
,
{
String
suffix
=
defaultSuffixJpeg
,
})
:
super
.
asset
(
source
,
suffix:
suffix
);
WeChatImage
.
file
(
File
source
,
{
String
suffix
=
defaultSuffixJpeg
})
:
super
.
file
(
source
,
suffix:
suffix
);
WeChatImage
.
file
(
File
source
,
{
String
suffix
=
defaultSuffixJpeg
,
})
:
super
.
file
(
source
,
suffix:
suffix
);
WeChatImage
.
binary
(
Uint8List
source
,
{
String
suffix
=
defaultSuffixJpeg
})
:
super
.
binary
(
source
,
suffix:
suffix
);
WeChatImage
.
binary
(
Uint8List
source
,
{
String
suffix
=
defaultSuffixJpeg
,
})
:
super
.
binary
(
source
,
suffix:
suffix
);
}
class
WeChatFile
{
final
dynamic
source
;
final
FileSchema
schema
;
final
String
suffix
;
/// [source] must begin with http or https
WeChatFile
.
network
(
String
source
,
{
String
?
suffix
})
:
assert
(
source
.
startsWith
(
"http"
)),
this
.
source
=
source
,
this
.
schema
=
FileSchema
.
NETWORK
,
this
.
suffix
=
source
.
readSuffix
(
suffix
,
defaultSuffixTxt
);
WeChatFile
.
network
(
String
source
,
{
String
?
suffix
,
})
:
assert
(
source
.
startsWith
(
'http'
)),
source
=
source
,
schema
=
FileSchema
.
NETWORK
,
suffix
=
source
.
readSuffix
(
suffix
,
defaultSuffixTxt
);
///[source] path of the image, like '/asset/image.pdf?package=flutter',
///the query param package in [source] only available when you want to specify the package of image
WeChatFile
.
asset
(
String
source
,
{
String
?
suffix
})
:
assert
(
source
.
trim
().
isNotEmpty
),
WeChatFile
.
asset
(
String
source
,
{
String
?
suffix
,
})
:
assert
(
source
.
trim
().
isNotEmpty
),
this
.
source
=
source
,
this
.
schema
=
FileSchema
.
ASSET
,
this
.
suffix
=
source
.
readSuffix
(
suffix
,
defaultSuffixTxt
);
WeChatFile
.
file
(
File
source
,
{
String
suffix
=
defaultSuffixTxt
})
:
this
.
source
=
source
.
path
,
this
.
schema
=
FileSchema
.
FILE
,
this
.
suffix
=
source
.
path
.
readSuffix
(
suffix
,
defaultSuffixTxt
);
WeChatFile
.
file
(
File
source
,
{
String
suffix
=
defaultSuffixTxt
,
})
:
source
=
source
.
path
,
schema
=
FileSchema
.
FILE
,
suffix
=
source
.
path
.
readSuffix
(
suffix
,
defaultSuffixTxt
);
WeChatFile
.
binary
(
Uint8List
source
,
{
String
suffix
=
defaultSuffixTxt
})
:
assert
(
suffix
.
trim
().
isNotEmpty
),
this
.
source
=
source
,
this
.
schema
=
FileSchema
.
BINARY
,
this
.
suffix
=
suffix
;
WeChatFile
.
binary
(
Uint8List
source
,
{
String
suffix
=
defaultSuffixTxt
,
})
:
assert
(
suffix
.
trim
().
isNotEmpty
),
source
=
source
,
schema
=
FileSchema
.
BINARY
,
suffix
=
suffix
;
Map
toMap
()
=>
{
"source"
:
source
,
"schema"
:
schema
.
index
,
"suffix"
:
suffix
}
;
}
final
dynamic
source
;
final
FileSchema
schema
;
final
String
suffix
;
///Types of image, usually there are for types listed below.
///[FileSchema.NETWORK] is online images.
///[FileSchema.ASSET] is flutter asset image.
///[FileSchema.BINARY] is binary image, shall be be [Uint8List]
///[FileSchema.FILE] is local file, usually not comes from flutter asset.
enum
FileSchema
{
NETWORK
,
ASSET
,
FILE
,
BINARY
,
Map
toMap
()
=>
{
'source'
:
source
,
'schema'
:
schema
.
index
,
'suffix'
:
suffix
};
}
/// Types of image, usually there are for types listed below.
///
/// [NETWORK] is online images.
/// [ASSET] is flutter asset image.
/// [BINARY] is binary image, shall be be [Uint8List]
/// [FILE] is local file, usually not comes from flutter asset.
enum
FileSchema
{
NETWORK
,
ASSET
,
FILE
,
BINARY
}
extension
_FileSuffix
on
String
{
/// returns [suffix] if [suffix] not blank.
/// If [suffix] is blank, then try to read from url
/// if suffix in url not found, then return jpg as default.
String
readSuffix
(
String
?
suffix
,
String
defaultSuffix
)
{
if
(
suffix
!=
null
&&
suffix
.
trim
().
isNotEmpty
)
{
if
(
suffix
.
startsWith
(
"."
))
{
if
(
suffix
.
startsWith
(
'.'
))
{
return
suffix
;
}
else
{
return
".
$suffix
"
;
return
'.
$suffix
'
;
}
}
var
path
=
Uri
.
parse
(
this
).
path
;
var
index
=
path
.
lastIndexOf
(
"."
);
var
index
=
path
.
lastIndexOf
(
'.'
);
if
(
index
>=
0
)
{
return
path
.
substring
(
index
);
...
...
test/fluwx_iml_test.dart
浏览文件 @
71564dad
...
...
@@ -9,19 +9,23 @@ void main() {
setUp
(()
{
channel
.
setMockMethodCallHandler
((
MethodCall
methodCall
)
async
{
if
(
methodCall
.
method
==
"registerApp"
)
{
if
(
methodCall
.
arguments
[
"appId"
]
==
"wx13124324324"
)
{
if
(
methodCall
.
method
==
'registerApp'
)
{
if
(
methodCall
.
arguments
[
'appId'
]
==
'wx13124324324'
)
{
return
Future
.
value
(
true
);
}
else
{
return
Future
.
value
(
false
);
}
}
else
if
(
methodCall
.
method
==
"shareText"
)
{
}
else
if
(
methodCall
.
method
==
'shareText'
)
{
channel
.
invokeMethod
(
"onShareResponse"
,
{
"type"
:
1
,
"errCode"
:
1
,
"errStr"
:
"hehe"
});
'onShareResponse'
,
{
'type'
:
1
,
'errCode'
:
1
,
'errStr'
:
'hehe'
},
);
return
Future
.
value
(
true
);
}
else
if
(
methodCall
.
method
==
"shareImage"
)
{
}
else
if
(
methodCall
.
method
==
'shareImage'
)
{
channel
.
invokeMethod
(
"onShareResponse"
,
{
"type"
:
1
,
"errCode"
:
0
,
"errStr"
:
""
});
'onShareResponse'
,
{
'type'
:
1
,
'errCode'
:
0
,
'errStr'
:
''
},
);
return
Future
.
value
(
true
);
}
return
'42'
;
...
...
@@ -32,34 +36,38 @@ void main() {
channel
.
setMockMethodCallHandler
(
null
);
});
group
(
"register"
,
()
{
test
(
"success"
,
()
async
{
expect
(
await
fluwx
.
registerWxApi
(
appId:
"wx13124324324"
),
true
);
group
(
'register'
,
()
{
test
(
'success'
,
()
async
{
expect
(
await
fluwx
.
registerWxApi
(
appId:
'wx13124324324'
),
true
);
});
test
(
"failed"
,
()
async
{
expect
(
await
fluwx
.
registerWxApi
(
appId:
"wx131256"
),
false
);
test
(
'failed'
,
()
async
{
expect
(
await
fluwx
.
registerWxApi
(
appId:
'wx131256'
),
false
);
});
});
group
(
"share"
,
()
{
test
(
"text"
,
()
async
{
group
(
'share'
,
()
{
test
(
'text'
,
()
async
{
expect
(
await
fluwx
.
shareToWeChat
(
fluwx
.
WeChatShareTextModel
(
"text"
)),
true
);
await
fluwx
.
shareToWeChat
(
fluwx
.
WeChatShareTextModel
(
'text'
)),
true
,
);
});
test
(
"shareImage"
,
()
async
{
test
(
'shareImage'
,
()
async
{
expect
(
await
fluwx
.
shareToWeChat
(
fluwx
.
WeChatShareImageModel
(
fluwx
.
WeChatImage
.
network
(
"http://flutter.dev"
))),
true
);
await
fluwx
.
shareToWeChat
(
fluwx
.
WeChatShareImageModel
(
fluwx
.
WeChatImage
.
network
(
'http://flutter.dev'
),
),
),
true
,
);
});
});
group
(
"learn"
,
()
{
test
(
"description"
,
()
async
{
print
(
"argumentsss"
);
group
(
'learn'
,
()
{
test
(
'description'
,
()
async
{
print
(
'argumentsss'
);
});
});
}
test/response/wechat_response_test.dart
浏览文件 @
71564dad
...
...
@@ -21,97 +21,103 @@ import 'package:flutter_test/flutter_test.dart';
import
'package:fluwx/fluwx.dart'
;
void
main
(
)
{
group
(
"create response"
,
()
{
test
(
"WeChatShareResponse"
,
()
{
group
(
'create response'
,
()
{
test
(
'WeChatShareResponse'
,
()
{
var
response
=
BaseWeChatResponse
.
create
(
"onShareResponse"
,
{
"type"
:
1
,
"errCode"
:
1
,
"errStr"
:
"hehe"
});
'onShareResponse'
,
{
'type'
:
1
,
'errCode'
:
1
,
'errStr'
:
'hehe'
},
);
expect
(
response
is
WeChatShareResponse
,
true
);
var
casted
=
response
as
WeChatShareResponse
;
expect
(
casted
.
type
,
1
);
expect
(
casted
.
errCode
,
1
);
expect
(
casted
.
errStr
,
"hehe"
);
expect
(
casted
.
errStr
,
'hehe'
);
});
test
(
"WeChatAuthResponse"
,
()
{
var
response
=
BaseWeChatResponse
.
create
(
"onAuthResponse"
,
{
"type"
:
1
,
"errCode"
:
1
,
"errStr"
:
"hehe"
,
"country"
:
"cn"
,
"lang"
:
"lang"
,
"code"
:
"code"
,
"state"
:
"ok"
test
(
'WeChatAuthResponse'
,
()
{
var
response
=
BaseWeChatResponse
.
create
(
'onAuthResponse'
,
{
'type'
:
1
,
'errCode'
:
1
,
'errStr'
:
'hehe'
,
'country'
:
'cn'
,
'lang'
:
'lang'
,
'code'
:
'code'
,
'state'
:
'ok'
});
expect
(
response
is
WeChatAuthResponse
,
true
);
var
casted
=
response
as
WeChatAuthResponse
;
expect
(
casted
.
type
,
1
);
expect
(
casted
.
errCode
,
1
);
expect
(
casted
.
errStr
,
"hehe"
);
expect
(
casted
.
country
,
"cn"
);
expect
(
casted
.
lang
,
"lang"
);
expect
(
casted
.
code
,
"code"
);
expect
(
casted
.
state
,
"ok"
);
expect
(
casted
.
errStr
,
'hehe'
);
expect
(
casted
.
country
,
'cn'
);
expect
(
casted
.
lang
,
'lang'
);
expect
(
casted
.
code
,
'code'
);
expect
(
casted
.
state
,
'ok'
);
});
test
(
"onLaunchMiniProgramResponse"
,
()
{
var
response
=
BaseWeChatResponse
.
create
(
"onLaunchMiniProgramResponse"
,
{
"type"
:
1
,
"errCode"
:
1
,
"errStr"
:
"hehe"
,
"extMsg"
:
"extMsg"
});
test
(
'onLaunchMiniProgramResponse'
,
()
{
var
response
=
BaseWeChatResponse
.
create
(
'onLaunchMiniProgramResponse'
,
{
'type'
:
1
,
'errCode'
:
1
,
'errStr'
:
'hehe'
,
'extMsg'
:
'extMsg'
},
);
expect
(
response
is
WeChatLaunchMiniProgramResponse
,
true
);
var
casted
=
response
as
WeChatLaunchMiniProgramResponse
;
expect
(
casted
.
type
,
1
);
expect
(
casted
.
errCode
,
1
);
expect
(
casted
.
errStr
,
"hehe"
);
expect
(
casted
.
extMsg
,
"extMsg"
);
expect
(
casted
.
errStr
,
'hehe'
);
expect
(
casted
.
extMsg
,
'extMsg'
);
});
test
(
"WeChatPaymentResponse"
,
()
{
var
response
=
BaseWeChatResponse
.
create
(
"onPayResponse"
,
{
"type"
:
1
,
"errCode"
:
1
,
"errStr"
:
"hehe"
,
"extData"
:
"extData"
});
test
(
'WeChatPaymentResponse'
,
()
{
var
response
=
BaseWeChatResponse
.
create
(
'onPayResponse'
,
{
'type'
:
1
,
'errCode'
:
1
,
'errStr'
:
'hehe'
,
'extData'
:
'extData'
},
);
expect
(
response
is
WeChatPaymentResponse
,
true
);
var
casted
=
response
as
WeChatPaymentResponse
;
expect
(
casted
.
type
,
1
);
expect
(
casted
.
errCode
,
1
);
expect
(
casted
.
errStr
,
"hehe"
);
expect
(
casted
.
extData
,
"extData"
);
expect
(
casted
.
errStr
,
'hehe'
);
expect
(
casted
.
extData
,
'extData'
);
});
test
(
"WeChatSubscribeMsgResponse"
,
()
{
var
response
=
BaseWeChatResponse
.
create
(
"onSubscribeMsgResp"
,
{
"type"
:
1
,
"errCode"
:
1
,
"errStr"
:
"hehe"
,
"openid"
:
"425235131"
,
"templateId"
:
"4252345"
,
"action"
:
"action"
,
"reserved"
:
"reserved"
,
"scene"
:
1
test
(
'WeChatSubscribeMsgResponse'
,
()
{
var
response
=
BaseWeChatResponse
.
create
(
'onSubscribeMsgResp'
,
{
'type'
:
1
,
'errCode'
:
1
,
'errStr'
:
'hehe'
,
'openid'
:
'425235131'
,
'templateId'
:
'4252345'
,
'action'
:
'action'
,
'reserved'
:
'reserved'
,
'scene'
:
1
});
expect
(
response
is
WeChatSubscribeMsgResponse
,
true
);
var
casted
=
response
as
WeChatSubscribeMsgResponse
;
expect
(
casted
.
errCode
,
1
);
expect
(
casted
.
errStr
,
"hehe"
);
expect
(
casted
.
openid
,
"425235131"
);
expect
(
casted
.
templateId
,
"4252345"
);
expect
(
casted
.
action
,
"action"
);
expect
(
casted
.
reserved
,
"reserved"
);
expect
(
casted
.
errStr
,
'hehe'
);
expect
(
casted
.
openid
,
'425235131'
);
expect
(
casted
.
templateId
,
'4252345'
);
expect
(
casted
.
action
,
'action'
);
expect
(
casted
.
reserved
,
'reserved'
);
expect
(
casted
.
scene
,
1
);
});
test
(
"WeChatAutoDeductResponse"
,
()
{
var
response
=
BaseWeChatResponse
.
create
(
"onAutoDeductResponse"
,
{
"type"
:
1
,
"errCode"
:
0
,
"errStr"
:
"hehe"
,
"businessType"
:
2
,
"resultInfo"
:
"resultInfo"
test
(
'WeChatAutoDeductResponse'
,
()
{
var
response
=
BaseWeChatResponse
.
create
(
'onAutoDeductResponse'
,
{
'type'
:
1
,
'errCode'
:
0
,
'errStr'
:
'hehe'
,
'businessType'
:
2
,
'resultInfo'
:
'resultInfo'
});
expect
(
response
is
WeChatOpenBusinessWebviewResponse
,
true
);
var
casted
=
response
as
WeChatOpenBusinessWebviewResponse
;
assert
(
casted
.
isSuccessful
);
expect
(
casted
.
type
,
1
);
expect
(
casted
.
errCode
,
0
);
expect
(
casted
.
errStr
,
"hehe"
);
expect
(
casted
.
resultInfo
,
"resultInfo"
);
expect
(
casted
.
errStr
,
'hehe'
);
expect
(
casted
.
resultInfo
,
'resultInfo'
);
expect
(
casted
.
businessType
,
2
);
});
});
...
...
test/share/wechat_share_image_model_test.dart
浏览文件 @
71564dad
...
...
@@ -18,35 +18,38 @@
*/
import
'package:flutter_test/flutter_test.dart'
;
import
'package:fluwx/fluwx.dart'
;
import
'package:fluwx/src/share/share_models.dart'
;
import
'package:fluwx/src/wechat_enums.dart'
;
void
main
(
)
{
test
(
"test create WeChatShareImageModel with thumbnail"
,
()
{
var
image
=
WeChatImage
.
network
(
"http://openflutter.dev/fluwx.png"
);
var
thumbnail
=
WeChatImage
.
network
(
"http://openflutter.dev/fluwx.png"
);
var
model
=
WeChatShareImageModel
(
image
,
scene:
WeChatScene
.
FAVORITE
,
thumbnail:
thumbnail
);
test
(
'test create WeChatShareImageModel with thumbnail'
,
()
{
var
image
=
WeChatImage
.
network
(
'http://openflutter.dev/fluwx.png'
);
var
thumbnail
=
WeChatImage
.
network
(
'http://openflutter.dev/fluwx.png'
);
var
model
=
WeChatShareImageModel
(
image
,
scene:
WeChatScene
.
FAVORITE
,
thumbnail:
thumbnail
,
);
expect
(
model
.
source
,
image
);
expect
(
model
.
scene
,
WeChatScene
.
FAVORITE
);
expect
(
model
.
thumbnail
,
thumbnail
);
});
test
(
"test create WeChatShareImageModel without thumbnail"
,
()
{
var
image
=
WeChatImage
.
network
(
"http://openflutter.dev/fluwx.png"
);
test
(
'test create WeChatShareImageModel without thumbnail'
,
()
{
var
image
=
WeChatImage
.
network
(
'http://openflutter.dev/fluwx.png'
);
var
model
=
WeChatShareImageModel
(
image
,
scene:
WeChatScene
.
FAVORITE
);
expect
(
model
.
source
,
image
);
expect
(
model
.
scene
,
WeChatScene
.
FAVORITE
);
expect
(
model
.
thumbnail
,
image
);
});
test
(
"test WeChatShareImageModel toMap"
,
()
{
var
image
=
WeChatImage
.
network
(
"http://openflutter.dev/fluwx.png"
);
var
thumbnail
=
WeChatImage
.
network
(
"http://openflutter.dev/fluwx.png"
);
var
map
=
WeChatShareImageModel
(
image
,
scene:
WeChatScene
.
FAVORITE
,
thumbnail:
thumbnail
)
.
toMap
();
assert
(
map
[
"thumbnail"
]
!=
null
);
expect
(
map
[
"thumbnail"
][
"source"
],
"http://openflutter.dev/fluwx.png"
);
test
(
'test WeChatShareImageModel toMap'
,
()
{
var
image
=
WeChatImage
.
network
(
'http://openflutter.dev/fluwx.png'
);
var
thumbnail
=
WeChatImage
.
network
(
'http://openflutter.dev/fluwx.png'
);
var
map
=
WeChatShareImageModel
(
image
,
scene:
WeChatScene
.
FAVORITE
,
thumbnail:
thumbnail
,
).
toMap
();
assert
(
map
[
'thumbnail'
]
!=
null
);
expect
(
map
[
'thumbnail'
][
'source'
],
'http://openflutter.dev/fluwx.png'
);
});
}
test/share/wechat_share_mini_program_model_test.dart
浏览文件 @
71564dad
...
...
@@ -18,8 +18,6 @@
*/
import
'package:flutter_test/flutter_test.dart'
;
import
'package:fluwx/fluwx.dart'
;
import
'package:fluwx/src/share/share_models.dart'
;
import
'package:fluwx/src/wechat_enums.dart'
;
void
main
(
)
{
group
(
"construct"
,
()
{
...
...
test/share/wechat_share_text_model_test.dart
浏览文件 @
71564dad
...
...
@@ -21,15 +21,15 @@ import 'package:fluwx/src/share/share_models.dart';
import
'package:fluwx/src/wechat_enums.dart'
;
void
main
(
)
{
test
(
"create WeChatTextModel"
,
()
{
var
model
=
WeChatShareTextModel
(
"text"
,
scene:
WeChatScene
.
FAVORITE
);
expect
(
model
.
source
,
"text"
);
test
(
'create WeChatTextModel'
,
()
{
var
model
=
WeChatShareTextModel
(
'text'
,
scene:
WeChatScene
.
FAVORITE
);
expect
(
model
.
source
,
'text'
);
expect
(
model
.
scene
,
WeChatScene
.
FAVORITE
);
});
test
(
"WeChatTextModel toMap"
,
()
{
var
map
=
WeChatShareTextModel
(
"text"
,
scene:
WeChatScene
.
FAVORITE
).
toMap
();
expect
(
map
[
"source"
],
"text"
);
expect
(
map
[
"scene"
],
2
);
test
(
'WeChatTextModel toMap'
,
()
{
var
map
=
WeChatShareTextModel
(
'text'
,
scene:
WeChatScene
.
FAVORITE
).
toMap
();
expect
(
map
[
'source'
],
'text'
);
expect
(
map
[
'scene'
],
2
);
});
}
test/wechat_image_test.dart
浏览文件 @
71564dad
...
...
@@ -17,30 +17,36 @@
* the License.
*/
import
'package:flutter_test/flutter_test.dart'
;
import
'package:fluwx/fluwx.dart'
;
import
'package:fluwx/src/wechat_file.dart'
;
void
main
(
)
{
test
(
"test WeChatImage.fromNetwork"
,
()
{
var
withSuffixImage
=
WeChatImage
.
network
(
"http://image.openflutter.dev/fluwx.png"
);
expect
(
withSuffixImage
.
source
,
"http://image.openflutter.dev/fluwx.png"
);
expect
(
withSuffixImage
.
suffix
,
".png"
);
test
(
'test WeChatImage.fromNetwork'
,
()
{
var
withSuffixImage
=
WeChatImage
.
network
(
'http://image.openflutter.dev/fluwx.png'
,
);
expect
(
withSuffixImage
.
source
,
'http://image.openflutter.dev/fluwx.png'
);
expect
(
withSuffixImage
.
suffix
,
'.png'
);
expect
(
FileSchema
.
NETWORK
,
withSuffixImage
.
schema
);
var
withNoSuffixNoUrlSuffixImage
=
WeChatImage
.
network
(
"http://image.openflutter.dev/fluwx"
);
expect
(
"http://image.openflutter.dev/fluwx"
,
withNoSuffixNoUrlSuffixImage
.
source
);
expect
(
withNoSuffixNoUrlSuffixImage
.
suffix
,
".jpeg"
);
var
withNoSuffixNoUrlSuffixImage
=
WeChatImage
.
network
(
'http://image.openflutter.dev/fluwx'
,
);
expect
(
'http://image.openflutter.dev/fluwx'
,
withNoSuffixNoUrlSuffixImage
.
source
,
);
expect
(
withNoSuffixNoUrlSuffixImage
.
suffix
,
'.jpeg'
);
expect
(
FileSchema
.
NETWORK
,
withSuffixImage
.
schema
);
var
withSpecifiedSuffixImage
=
WeChatImage
.
network
(
"http://image.openflutter.dev/fluwx.jpeg"
,
suffix:
".png"
);
expect
(
withSpecifiedSuffixImage
.
source
,
"http://image.openflutter.dev/fluwx.jpeg"
);
expect
(
withSpecifiedSuffixImage
.
suffix
,
".png"
);
'http://image.openflutter.dev/fluwx.jpeg'
,
suffix:
'.png'
,
);
expect
(
withSpecifiedSuffixImage
.
source
,
'http://image.openflutter.dev/fluwx.jpeg'
,
);
expect
(
withSpecifiedSuffixImage
.
suffix
,
'.png'
);
expect
(
withSpecifiedSuffixImage
.
schema
,
FileSchema
.
NETWORK
);
});
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论