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

reformat code

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