提交 b1e3a51d authored 作者: JarvanMo's avatar JarvanMo

format code

上级 a335eb8e
......@@ -23,7 +23,6 @@ import 'wechat_type.dart';
import 'package:flutter/foundation.dart';
import 'utils/utils.dart';
StreamController<WeChatShareResponse> _responseShareController =
new StreamController.broadcast();
......@@ -42,10 +41,11 @@ StreamController<WeChatPaymentResponse> _responsePaymentController =
Stream<WeChatPaymentResponse> get responseFromPayment =>
_responsePaymentController.stream;
Stream<WeChatLaunchMiniProgramResponse> get responseFromLaunchMiniProgram => _responseLaunchMiniProgramController.stream;
Stream<WeChatLaunchMiniProgramResponse> get responseFromLaunchMiniProgram =>
_responseLaunchMiniProgramController.stream;
StreamController<WeChatLaunchMiniProgramResponse> _responseLaunchMiniProgramController =
new StreamController.broadcast();
StreamController<WeChatLaunchMiniProgramResponse>
_responseLaunchMiniProgramController = new StreamController.broadcast();
final MethodChannel _channel = const MethodChannel('com.jarvanmo/fluwx')
..setMethodCallHandler(_handler);
......@@ -94,7 +94,11 @@ Future register(
}
///we don't need the response any longer if params are true.
void dispose({shareResponse: true, authResponse: true, paymentResponse: true,launchMiniProgramResponse:true}) {
void dispose(
{shareResponse: true,
authResponse: true,
paymentResponse: true,
launchMiniProgramResponse: true}) {
if (shareResponse) {
_responseShareController.close();
}
......@@ -130,19 +134,26 @@ Future share(WeChatShareModel model) async {
}
}
Future sendAuth({ String openId,@required String scope,String state}) async {
Future sendAuth({String openId, @required String scope, String state}) async {
// "scope": scope, "state": state, "openId": openId
assert(scope != null && scope.trim().isNotEmpty);
return await _channel.invokeMethod("sendAuth", {"scope": scope, "state": state, "openId": openId});
return await _channel.invokeMethod(
"sendAuth", {"scope": scope, "state": state, "openId": openId});
}
Future launchMiniProgram({@required String username, String path, WXMiniProgramType miniProgramType = WXMiniProgramType.RELEASE}) async {
Future launchMiniProgram(
{@required String username,
String path,
WXMiniProgramType miniProgramType = WXMiniProgramType.RELEASE}) async {
assert(username != null && username.trim().isNotEmpty);
return await _channel.invokeMethod("launchMiniProgram", {"userName": username, "path": path, "miniProgramType": miniProgramTypeToInt(miniProgramType)});
return await _channel.invokeMethod("launchMiniProgram", {
"userName": username,
"path": path,
"miniProgramType": miniProgramTypeToInt(miniProgramType)
});
}
Future isWeChatInstalled() async {
return await _channel.invokeMethod("isWeChatInstalled");
}
......@@ -169,5 +180,3 @@ Future pay(
"extData": extData,
});
}
......@@ -76,7 +76,6 @@ class WeChatAuthResponse {
androidTransaction = map["transaction"];
}
class WeChatLaunchMiniProgramResponse {
final String errStr;
final int type;
......@@ -96,7 +95,6 @@ class WeChatLaunchMiniProgramResponse {
extMsg = map["extMsg"];
}
class WeChatPaymentResponse {
final String errStr;
final int type;
......
......@@ -17,6 +17,7 @@ import 'package:flutter/foundation.dart';
import '../wechat_type.dart';
import '../utils/utils.dart';
const String _scene = "scene";
const String _transaction = "transaction";
const String _thumbnail = "thumbnail";
......@@ -80,8 +81,6 @@ class WeChatShareTextModel extends WeChatShareModel {
/// [hdImagePath] only works with iOS
///
class WeChatShareMiniProgramModel extends WeChatShareModel {
final String webPageUrl;
final WXMiniProgramType miniProgramType;
final String userName;
......
import '../wechat_type.dart';
int miniProgramTypeToInt(WXMiniProgramType type){
switch(type){
case WXMiniProgramType.PREVIEW:
return 2;
case WXMiniProgramType.TEST:
return 1;
case WXMiniProgramType.RELEASE:
return 0;
int miniProgramTypeToInt(WXMiniProgramType type) {
switch (type) {
case WXMiniProgramType.PREVIEW:
return 2;
case WXMiniProgramType.TEST:
return 1;
case WXMiniProgramType.RELEASE:
return 0;
}
return 0;
}
\ No newline at end of file
}
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
///[WXMiniProgramType.RELEASE]正式版
///[WXMiniProgramType.TEST]测试版
///[WXMiniProgramType.PREVIEW]预览版
......@@ -21,4 +22,4 @@ enum WXMiniProgramType { RELEASE, TEST, PREVIEW }
///[WeChatScene.SESSION]会话
///[WeChatScene.TIMELINE]朋友圈
///[WeChatScene.FAVORITE]收藏
enum WeChatScene { SESSION, TIMELINE, FAVORITE }
\ No newline at end of file
enum WeChatScene { SESSION, TIMELINE, FAVORITE }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论