提交 56bcb73d authored 作者: JarvanMo's avatar JarvanMo

reformat code

上级 fdafc28a
......@@ -51,7 +51,8 @@ class _PayPageState extends State<PayPage> {
Map<String, dynamic> result = json.decode(data);
print(result['appid']);
print(result["timestamp"]);
fluwx.payWithWeChat(
fluwx
.payWithWeChat(
appId: result['appid'].toString(),
partnerId: result['partnerid'].toString(),
prepayId: result['prepayid'].toString(),
......
......@@ -72,9 +72,8 @@ class _ShareImagePageState extends State<ShareImagePage> {
new Radio<WeChatScene>(
value: WeChatScene.SESSION,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("会话")
],
......@@ -84,9 +83,8 @@ class _ShareImagePageState extends State<ShareImagePage> {
new Radio<WeChatScene>(
value: WeChatScene.TIMELINE,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("朋友圈")
],
......@@ -96,9 +94,8 @@ class _ShareImagePageState extends State<ShareImagePage> {
new Radio<WeChatScene>(
value: WeChatScene.FAVORITE,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("收藏")
],
......
......@@ -75,8 +75,7 @@ class _ShareMiniProgramPageState extends State<ShareMiniProgramPage> {
decoration: InputDecoration(labelText: "description"),
),
new TextField(
controller:
TextEditingController(text: "images/logo.png"),
controller: TextEditingController(text: "images/logo.png"),
onChanged: (str) {
_thumbnail = str;
},
......@@ -95,8 +94,7 @@ class _ShareMiniProgramPageState extends State<ShareMiniProgramPage> {
title: _title,
path: _path,
description: _description,
thumbnail: WeChatImage.network(_thumbnail)
);
thumbnail: WeChatImage.network(_thumbnail));
shareToWeChat(model);
}
}
......@@ -70,8 +70,7 @@ class _ShareMusicPageState extends State<ShareMusicPage> {
decoration: InputDecoration(labelText: "description"),
),
new TextField(
controller:
TextEditingController(text: "images/logo.png"),
controller: TextEditingController(text: "images/logo.png"),
onChanged: (str) {
_thumnail = str;
},
......@@ -85,9 +84,8 @@ class _ShareMusicPageState extends State<ShareMusicPage> {
new Radio<WeChatScene>(
value: WeChatScene.SESSION,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("会话")
],
......@@ -97,9 +95,8 @@ class _ShareMusicPageState extends State<ShareMusicPage> {
new Radio<WeChatScene>(
value: WeChatScene.TIMELINE,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("朋友圈")
],
......@@ -109,9 +106,8 @@ class _ShareMusicPageState extends State<ShareMusicPage> {
new Radio<WeChatScene>(
value: WeChatScene.FAVORITE,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("收藏")
],
......
......@@ -48,9 +48,8 @@ class _ShareTextPageState extends State<ShareTextPage> {
new Radio<WeChatScene>(
value: WeChatScene.SESSION,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("会话")
],
......@@ -60,9 +59,8 @@ class _ShareTextPageState extends State<ShareTextPage> {
new Radio<WeChatScene>(
value: WeChatScene.TIMELINE,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("朋友圈")
],
......@@ -72,9 +70,8 @@ class _ShareTextPageState extends State<ShareTextPage> {
new Radio<WeChatScene>(
value: WeChatScene.FAVORITE,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("收藏")
],
......
......@@ -69,8 +69,7 @@ class _ShareMusicPageState extends State<ShareVideoPage> {
decoration: InputDecoration(labelText: "description"),
),
new TextField(
controller:
TextEditingController(text: "images/logo.png"),
controller: TextEditingController(text: "images/logo.png"),
onChanged: (str) {
_thumnail = str;
},
......@@ -84,9 +83,8 @@ class _ShareMusicPageState extends State<ShareVideoPage> {
new Radio<WeChatScene>(
value: WeChatScene.SESSION,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("会话")
],
......@@ -96,9 +94,8 @@ class _ShareMusicPageState extends State<ShareVideoPage> {
new Radio<WeChatScene>(
value: WeChatScene.TIMELINE,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("朋友圈")
],
......@@ -108,9 +105,8 @@ class _ShareMusicPageState extends State<ShareVideoPage> {
new Radio<WeChatScene>(
value: WeChatScene.FAVORITE,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("收藏")
],
......
......@@ -53,8 +53,7 @@ class ShareWebPagePageState extends State<ShareWebPagePage> {
decoration: InputDecoration(labelText: "thumbnail"),
),
new TextField(
controller:
TextEditingController(text: "images/logo.png"),
controller: TextEditingController(text: "images/logo.png"),
onChanged: (str) {
_thumnail = str;
},
......@@ -68,9 +67,8 @@ class ShareWebPagePageState extends State<ShareWebPagePage> {
new Radio<WeChatScene>(
value: WeChatScene.SESSION,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("会话")
],
......@@ -80,9 +78,8 @@ class ShareWebPagePageState extends State<ShareWebPagePage> {
new Radio<WeChatScene>(
value: WeChatScene.TIMELINE,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("朋友圈")
],
......@@ -92,9 +89,8 @@ class ShareWebPagePageState extends State<ShareWebPagePage> {
new Radio<WeChatScene>(
value: WeChatScene.FAVORITE,
groupValue: scene,
onChanged: (v){
if(v!=null)
handleRadioValueChanged(v);
onChanged: (v) {
if (v != null) handleRadioValueChanged(v);
}),
const Text("收藏")
],
......
......@@ -88,10 +88,10 @@ Future<bool> registerWxApi(
Future<bool> shareToWeChat(WeChatShareBaseModel model) async {
if (_shareModelMethodMapper.containsKey(model.runtimeType)) {
var methodChannel = _shareModelMethodMapper[model.runtimeType];
if(methodChannel == null)
throw ArgumentError.value("${model.runtimeType} method channel not found");
return await _channel.invokeMethod(
methodChannel , model.toMap());
if (methodChannel == null)
throw ArgumentError.value(
"${model.runtimeType} method channel not found");
return await _channel.invokeMethod(methodChannel, model.toMap());
} else {
return Future.error("no method mapper found[${model.runtimeType}]");
}
......@@ -104,7 +104,8 @@ Future<bool> shareToWeChat(WeChatShareBaseModel model) async {
/// Once AuthCode got, you need to request Access_Token
/// For more information please visit:
/// * https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419317851&token=
Future<bool> sendWeChatAuth({required String scope, String state="state"}) async {
Future<bool> sendWeChatAuth(
{required String scope, String state = "state"}) async {
assert(scope.trim().isNotEmpty);
return await _channel
.invokeMethod("sendAuth", {"scope": scope, "state": state});
......@@ -248,7 +249,7 @@ Future _methodHandler(MethodCall methodCall) {
///IOS only
Future<bool> authWeChatByPhoneLogin(
{required String scope, String state="state"}) async {
{required String scope, String state = "state"}) async {
return await _channel
.invokeMethod("authByPhoneLogin", {"scope": scope, "state": state});
}
......@@ -55,12 +55,11 @@ class BaseWeChatResponse {
/// create response from response pool
factory BaseWeChatResponse.create(String name, Map argument) {
var result = _nameAndResponseMapper[name];
if(result == null){
if (result == null) {
throw ArgumentError("Can't found instance of $name");
}
return result(argument);
}
}
class WeChatShareResponse extends BaseWeChatResponse {
......
......@@ -52,7 +52,7 @@ class WeChatShareTextModel implements WeChatShareBaseModel {
this.messageExt,
String? description,
String? title})
:this.title = title ?? source,
: this.title = title ?? source,
this.description = description ?? source;
@override
......@@ -101,8 +101,7 @@ class WeChatShareMiniProgramModel implements WeChatShareBaseModel {
this.messageAction,
this.messageExt,
this.compressThumbnail = true})
:
assert(webPageUrl.isNotEmpty),
: assert(webPageUrl.isNotEmpty),
assert(userName.isNotEmpty),
assert(path.isNotEmpty);
......@@ -148,7 +147,7 @@ class WeChatShareImageModel implements WeChatShareBaseModel {
this.messageAction,
this.messageExt,
this.compressThumbnail = true})
:this.thumbnail = thumbnail ?? source;
: this.thumbnail = thumbnail ?? source;
@override
Map toMap() {
......
......@@ -57,7 +57,7 @@ class WeChatFile {
this.suffix = source.readSuffix(suffix, defaultSuffixTxt);
WeChatFile.file(File source, {String suffix = defaultSuffixTxt})
:this.source = source.path,
: this.source = source.path,
this.schema = FileSchema.FILE,
this.suffix = source.path.readSuffix(suffix, defaultSuffixTxt);
......@@ -88,8 +88,7 @@ extension _FileSuffix on String {
/// 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 != null && suffix.trim().isNotEmpty) {
if (suffix.startsWith(".")) {
return suffix;
} else {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论