support null-safety (#42)

* support null-safety

* fix : null-aware operation warning

* fix
This commit is contained in:
Jochen
2021-03-18 22:53:55 +08:00
committed by GitHub
parent 294bcd279f
commit d1fc803dbf
15 changed files with 214 additions and 249 deletions

View File

@ -7,42 +7,42 @@ packages:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.5.0-nullsafety.1" version: "2.5.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0-nullsafety.1" version: "2.1.0"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0-nullsafety.3" version: "1.1.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0-nullsafety.1" version: "1.1.0"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.15.0-nullsafety.3" version: "1.15.0"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@ -70,7 +70,7 @@ packages:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:
@ -115,21 +115,21 @@ packages:
name: json_annotation name: json_annotation
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.1.1" version: "4.0.0"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.12.10-nullsafety.1" version: "0.12.10"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0-nullsafety.3" version: "1.3.0"
okhttp_kit: okhttp_kit:
dependency: "direct main" dependency: "direct main"
description: description:
@ -143,7 +143,7 @@ packages:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.0-nullsafety.1" version: "1.8.0"
path_provider: path_provider:
dependency: "direct main" dependency: "direct main"
description: description:
@ -218,28 +218,28 @@ packages:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.0-nullsafety.2" version: "1.8.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.10.0-nullsafety.1" version: "1.10.0"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0-nullsafety.1" version: "2.1.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0-nullsafety.1" version: "1.1.0"
tencent_kit: tencent_kit:
dependency: "direct main" dependency: "direct main"
description: description:
@ -253,28 +253,28 @@ packages:
name: term_glyph name: term_glyph
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.2.19-nullsafety.2" version: "0.2.19"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0-nullsafety.3" version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0-nullsafety.3" version: "2.1.0"
win32: win32:
dependency: transitive dependency: transitive
description: description:
@ -290,5 +290,5 @@ packages:
source: hosted source: hosted
version: "0.1.2" version: "0.1.2"
sdks: sdks:
dart: ">=2.10.0-110 <2.11.0" dart: ">=2.12.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0" flutter: ">=1.12.13+hotfix.5"

View File

@ -13,8 +13,8 @@ abstract class TencentApiResp {
@JsonKey( @JsonKey(
defaultValue: RET_SUCCESS, defaultValue: RET_SUCCESS,
) )
final int ret; final int? ret;
final String msg; final String? msg;
bool get isSuccessful => ret == RET_SUCCESS; bool get isSuccessful => ret == RET_SUCCESS;
} }

View File

@ -9,8 +9,8 @@ part 'tencent_user_info_resp.g.dart';
) )
class TencentUserInfoResp extends TencentApiResp { class TencentUserInfoResp extends TencentApiResp {
const TencentUserInfoResp({ const TencentUserInfoResp({
int ret, int? ret,
String msg, String? msg,
this.isLost, this.isLost,
this.nickname, this.nickname,
this.gender, this.gender,
@ -36,58 +36,58 @@ class TencentUserInfoResp extends TencentApiResp {
factory TencentUserInfoResp.fromJson(Map<String, dynamic> json) => factory TencentUserInfoResp.fromJson(Map<String, dynamic> json) =>
_$TencentUserInfoRespFromJson(json); _$TencentUserInfoRespFromJson(json);
final int isLost; final int? isLost;
final String nickname; final String? nickname;
final String gender; // 男/女 final String? gender; // 男/女
final int genderType; // 男/女 - 1 final int? genderType; // 男/女 - 1
final String province; final String? province;
final String city; final String? city;
final String year; final String? year;
final String constellation; final String? constellation;
final String figureurl; final String? figureurl;
@JsonKey( @JsonKey(
name: 'figureurl_1', name: 'figureurl_1',
) )
final String figureurl1; final String? figureurl1;
@JsonKey( @JsonKey(
name: 'figureurl_2', name: 'figureurl_2',
) )
final String figureurl2; final String? figureurl2;
final String figureurlQq; // 140 * 140 final String? figureurlQq; // 140 * 140
@JsonKey( @JsonKey(
name: 'figureurl_qq_1', name: 'figureurl_qq_1',
) )
final String figureurlQq1; // 大小为40×40像素的QQ头像URL。 final String? figureurlQq1; // 大小为40×40像素的QQ头像URL。
@JsonKey( @JsonKey(
name: 'figureurl_qq_2', name: 'figureurl_qq_2',
) )
final String final String?
figureurlQq2; // 大小为100×100像素的QQ头像URL。需要注意不是所有的用户都拥有QQ的100x100的头像但40x40像素则是一定会有。 figureurlQq2; // 大小为100×100像素的QQ头像URL。需要注意不是所有的用户都拥有QQ的100x100的头像但40x40像素则是一定会有。
final String figureurlType; final String? figureurlType;
final String isYellowVip; final String? isYellowVip;
final String vip; final String? vip;
final String yellowVipLevel; final String? yellowVipLevel;
final String level; final String? level;
final String isYellowYearVip; final String? isYellowYearVip;
bool get isMale => gender == ''; bool get isMale => gender == '';
bool get isFemale => gender == ''; bool get isFemale => gender == '';
String get headImgUrl { String? get headImgUrl {
if (figureurlQq != null && figureurlQq.isNotEmpty) { if (figureurlQq?.isNotEmpty != true) {
return figureurlQq; return figureurlQq;
} }
if (figureurlQq2 != null && figureurlQq2.isNotEmpty) { if (figureurlQq2?.isNotEmpty != true) {
return figureurlQq2; return figureurlQq2;
} }
if (figureurlQq1 != null && figureurlQq1.isNotEmpty) { if (figureurlQq1?.isNotEmpty != true) {
return figureurlQq1; return figureurlQq1;
} }
if (figureurl2 != null && figureurl2.isNotEmpty) { if (figureurl2?.isNotEmpty != true) {
return figureurl2; return figureurl2;
} }
if (figureurl1 != null && figureurl1.isNotEmpty) { if (figureurl1?.isNotEmpty != true) {
return figureurl1; return figureurl1;
} }
return figureurl; return figureurl;

View File

@ -8,28 +8,28 @@ part of 'tencent_user_info_resp.dart';
TencentUserInfoResp _$TencentUserInfoRespFromJson(Map<String, dynamic> json) { TencentUserInfoResp _$TencentUserInfoRespFromJson(Map<String, dynamic> json) {
return TencentUserInfoResp( return TencentUserInfoResp(
ret: json['ret'] as int ?? 0, ret: json['ret'] as int? ?? 0,
msg: json['msg'] as String, msg: json['msg'] as String?,
isLost: json['is_lost'] as int, isLost: json['is_lost'] as int?,
nickname: json['nickname'] as String, nickname: json['nickname'] as String?,
gender: json['gender'] as String, gender: json['gender'] as String?,
genderType: json['gender_type'] as int, genderType: json['gender_type'] as int?,
province: json['province'] as String, province: json['province'] as String?,
city: json['city'] as String, city: json['city'] as String?,
year: json['year'] as String, year: json['year'] as String?,
constellation: json['constellation'] as String, constellation: json['constellation'] as String?,
figureurl: json['figureurl'] as String, figureurl: json['figureurl'] as String?,
figureurl1: json['figureurl_1'] as String, figureurl1: json['figureurl_1'] as String?,
figureurl2: json['figureurl_2'] as String, figureurl2: json['figureurl_2'] as String?,
figureurlQq: json['figureurl_qq'] as String, figureurlQq: json['figureurl_qq'] as String?,
figureurlQq1: json['figureurl_qq_1'] as String, figureurlQq1: json['figureurl_qq_1'] as String?,
figureurlQq2: json['figureurl_qq_2'] as String, figureurlQq2: json['figureurl_qq_2'] as String?,
figureurlType: json['figureurl_type'] as String, figureurlType: json['figureurl_type'] as String?,
isYellowVip: json['is_yellow_vip'] as String, isYellowVip: json['is_yellow_vip'] as String?,
vip: json['vip'] as String, vip: json['vip'] as String?,
yellowVipLevel: json['yellow_vip_level'] as String, yellowVipLevel: json['yellow_vip_level'] as String?,
level: json['level'] as String, level: json['level'] as String?,
isYellowYearVip: json['is_yellow_year_vip'] as String, isYellowYearVip: json['is_yellow_year_vip'] as String?,
); );
} }

View File

@ -9,12 +9,12 @@ part 'tencent_login_resp.g.dart';
) )
class TencentLoginResp extends TencentSdkResp { class TencentLoginResp extends TencentSdkResp {
const TencentLoginResp({ const TencentLoginResp({
int ret, int? ret,
String msg, String? msg,
this.openid, required this.openid,
this.accessToken, required this.accessToken,
this.expiresIn, required this.expiresIn,
this.createAt, required this.createAt,
}) : super(ret: ret, msg: msg); }) : super(ret: ret, msg: msg);
factory TencentLoginResp.fromJson(Map<String, dynamic> json) => factory TencentLoginResp.fromJson(Map<String, dynamic> json) =>

View File

@ -8,8 +8,8 @@ part of 'tencent_login_resp.dart';
TencentLoginResp _$TencentLoginRespFromJson(Map<String, dynamic> json) { TencentLoginResp _$TencentLoginRespFromJson(Map<String, dynamic> json) {
return TencentLoginResp( return TencentLoginResp(
ret: json['ret'] as int ?? 0, ret: json['ret'] as int? ?? 0,
msg: json['msg'] as String, msg: json['msg'] as String?,
openid: json['openid'] as String, openid: json['openid'] as String,
accessToken: json['access_token'] as String, accessToken: json['access_token'] as String,
expiresIn: json['expires_in'] as int, expiresIn: json['expires_in'] as int,

View File

@ -20,8 +20,8 @@ abstract class TencentSdkResp {
@JsonKey( @JsonKey(
defaultValue: RET_SUCCESS, defaultValue: RET_SUCCESS,
) )
final int ret; final int? ret;
final String msg; final String? msg;
bool get isSuccessful => ret == RET_SUCCESS; bool get isSuccessful => ret == RET_SUCCESS;

View File

@ -9,8 +9,8 @@ part 'tencent_share_resp.g.dart';
) )
class TencentShareResp extends TencentSdkResp { class TencentShareResp extends TencentSdkResp {
const TencentShareResp({ const TencentShareResp({
int ret, int? ret,
String msg, String? msg,
}) : super(ret: ret, msg: msg); }) : super(ret: ret, msg: msg);
factory TencentShareResp.fromJson(Map<String, dynamic> json) => factory TencentShareResp.fromJson(Map<String, dynamic> json) =>

View File

@ -8,8 +8,8 @@ part of 'tencent_share_resp.dart';
TencentShareResp _$TencentShareRespFromJson(Map<String, dynamic> json) { TencentShareResp _$TencentShareRespFromJson(Map<String, dynamic> json) {
return TencentShareResp( return TencentShareResp(
ret: json['ret'] as int ?? 0, ret: json['ret'] as int? ?? 0,
msg: json['msg'] as String, msg: json['msg'] as String?,
); );
} }

View File

@ -8,11 +8,11 @@ part 'tencent_unionid_resp.g.dart';
) )
class TencentUnionidResp { class TencentUnionidResp {
const TencentUnionidResp({ const TencentUnionidResp({
this.error, required this.error,
this.errorDescription, required this.errorDescription,
this.clientId, required this.clientId,
this.openid, required this.openid,
this.unionid, required this.unionid,
}); });
factory TencentUnionidResp.fromJson(Map<String, dynamic> json) => factory TencentUnionidResp.fromJson(Map<String, dynamic> json) =>

View File

@ -8,7 +8,7 @@ part of 'tencent_unionid_resp.dart';
TencentUnionidResp _$TencentUnionidRespFromJson(Map<String, dynamic> json) { TencentUnionidResp _$TencentUnionidRespFromJson(Map<String, dynamic> json) {
return TencentUnionidResp( return TencentUnionidResp(
error: json['error'] as int ?? 0, error: json['error'] as int? ?? 0,
errorDescription: json['error_description'] as String, errorDescription: json['error_description'] as String,
clientId: json['client_id'] as String, clientId: json['client_id'] as String,
openid: json['openid'] as String, openid: json['openid'] as String,

View File

@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:tencent_kit/src/model/api/tencent_user_info_resp.dart'; import 'package:tencent_kit/src/model/api/tencent_user_info_resp.dart';
import 'package:tencent_kit/src/model/sdk/tencent_login_resp.dart'; import 'package:tencent_kit/src/model/sdk/tencent_login_resp.dart';
@ -71,10 +70,10 @@ class Tencent {
/// 向 Open_SDK 注册 /// 向 Open_SDK 注册
Future<void> registerApp({ Future<void> registerApp({
@required String appId, required String appId,
String universalLink, String? universalLink,
}) { }) {
assert(appId?.isNotEmpty ?? false); assert(appId.isNotEmpty);
return _channel.invokeMethod<void>( return _channel.invokeMethod<void>(
_METHOD_REGISTERAPP, _METHOD_REGISTERAPP,
<String, dynamic>{ <String, dynamic>{
@ -96,20 +95,20 @@ class Tencent {
} }
/// 检查QQ是否已安装 /// 检查QQ是否已安装
Future<bool> isQQInstalled() { Future<bool?> isQQInstalled() {
return _channel.invokeMethod<bool>(_METHOD_ISQQINSTALLED); return _channel.invokeMethod<bool>(_METHOD_ISQQINSTALLED);
} }
/// 检查QQ是否已安装 /// 检查QQ是否已安装
Future<bool> isTIMInstalled() { Future<bool?> isTIMInstalled() {
return _channel.invokeMethod<bool>(_METHOD_ISTIMINSTALLED); return _channel.invokeMethod<bool>(_METHOD_ISTIMINSTALLED);
} }
/// 登录 /// 登录
Future<void> login({ Future<void> login({
@required List<String> scope, required List<String> scope,
}) { }) {
assert(scope?.isNotEmpty ?? false); assert(scope.isNotEmpty);
return _channel.invokeMethod<void>( return _channel.invokeMethod<void>(
_METHOD_LOGIN, _METHOD_LOGIN,
<String, dynamic>{ <String, dynamic>{
@ -126,13 +125,13 @@ class Tencent {
/// 用户信息 /// 用户信息
/// https://wiki.connect.qq.com/get_user_info /// https://wiki.connect.qq.com/get_user_info
Future<TencentUserInfoResp> getUserInfo({ Future<TencentUserInfoResp> getUserInfo({
@required String appId, required String appId,
@required String openid, required String openid,
@required String accessToken, required String accessToken,
}) { }) {
assert(appId?.isNotEmpty ?? false); assert(appId.isNotEmpty);
assert(openid?.isNotEmpty ?? false); assert(openid.isNotEmpty);
assert(accessToken?.isNotEmpty ?? false); assert(accessToken.isNotEmpty);
return HttpClient() return HttpClient()
.getUrl(Uri.parse( .getUrl(Uri.parse(
'https://graph.qq.com/user/get_user_info?access_token=$accessToken&oauth_consumer_key=$appId&openid=$openid')) 'https://graph.qq.com/user/get_user_info?access_token=$accessToken&oauth_consumer_key=$appId&openid=$openid'))
@ -140,7 +139,7 @@ class Tencent {
return request.close(); return request.close();
}).then((HttpClientResponse response) async { }).then((HttpClientResponse response) async {
if (response.statusCode == HttpStatus.ok) { if (response.statusCode == HttpStatus.ok) {
ContentType contentType = response.headers.contentType; ContentType? contentType = response.headers.contentType;
Encoding encoding = Encoding.getByName(contentType?.charset) ?? utf8; Encoding encoding = Encoding.getByName(contentType?.charset) ?? utf8;
String content = await encoding.decodeStream(response); String content = await encoding.decodeStream(response);
return TencentUserInfoResp.fromJson( return TencentUserInfoResp.fromJson(
@ -154,10 +153,10 @@ class Tencent {
/// UnionID /// UnionID
/// https://wiki.connect.qq.com/unionid%E4%BB%8B%E7%BB%8D /// https://wiki.connect.qq.com/unionid%E4%BB%8B%E7%BB%8D
Future<TencentUnionidResp> getUnionId({ Future<TencentUnionidResp> getUnionId({
@required String accessToken, required String accessToken,
String unionid = '1', String unionid = '1',
}) { }) {
assert(accessToken?.isNotEmpty ?? false); assert(accessToken.isNotEmpty);
return HttpClient() return HttpClient()
.getUrl(Uri.parse( .getUrl(Uri.parse(
'https://graph.qq.com/oauth2.0/me?access_token=$accessToken&unionid=$unionid')) 'https://graph.qq.com/oauth2.0/me?access_token=$accessToken&unionid=$unionid'))
@ -165,16 +164,16 @@ class Tencent {
return request.close(); return request.close();
}).then((HttpClientResponse response) async { }).then((HttpClientResponse response) async {
if (response.statusCode == HttpStatus.ok) { if (response.statusCode == HttpStatus.ok) {
ContentType contentType = response.headers.contentType; ContentType? contentType = response.headers.contentType;
Encoding encoding = Encoding.getByName(contentType?.charset) ?? utf8; Encoding encoding = Encoding.getByName(contentType?.charset) ?? utf8;
String callback = await encoding.decodeStream(response); String callback = await encoding.decodeStream(response);
// 腾讯有毒 callback( $json ); // 腾讯有毒 callback( $json );
RegExp exp = RegExp(r'callback\( (.*) \)\;'); RegExp exp = RegExp(r'callback\( (.*) \)\;');
Match match = exp.firstMatch(callback); Match? match = exp.firstMatch(callback);
if (match.groupCount == 1) { if (match?.groupCount == 1) {
String content = match.group(1); String? content = match?.group(1);
return TencentUnionidResp.fromJson( return TencentUnionidResp.fromJson(
json.decode(content) as Map<String, dynamic>); json.decode(content ?? '') as Map<String, dynamic>);
} }
} }
throw HttpException( throw HttpException(
@ -184,18 +183,18 @@ class Tencent {
/// 分享 - 说说 /// 分享 - 说说
Future<void> shareMood({ Future<void> shareMood({
@required int scene, required int scene,
String summary, String? summary,
List<Uri> imageUris, List<Uri>? imageUris,
Uri videoUri, Uri? videoUri,
}) { }) {
assert(scene == TencentScene.SCENE_QZONE); assert(scene == TencentScene.SCENE_QZONE);
assert((summary?.isNotEmpty ?? false) || assert((summary?.isNotEmpty ?? false) ||
(imageUris?.isNotEmpty ?? false) || (imageUris?.isNotEmpty ?? false) ||
(videoUri != null && videoUri.isScheme(_SCHEME_FILE)) || (videoUri != null && videoUri.isScheme(_SCHEME_FILE)) ||
((imageUris?.isNotEmpty ?? false) && ((imageUris?.isNotEmpty ?? false) &&
imageUris.every((Uri element) => imageUris?.every((Uri element) =>
element != null && element.isScheme(_SCHEME_FILE)))); element.isScheme(_SCHEME_FILE)) == true));
return _channel.invokeMethod<void>( return _channel.invokeMethod<void>(
_METHOD_SHAREMOOD, _METHOD_SHAREMOOD,
<String, dynamic>{ <String, dynamic>{
@ -203,7 +202,7 @@ class Tencent {
if (summary?.isNotEmpty ?? false) _ARGUMENT_KEY_SUMMARY: summary, if (summary?.isNotEmpty ?? false) _ARGUMENT_KEY_SUMMARY: summary,
if (imageUris?.isNotEmpty ?? false) if (imageUris?.isNotEmpty ?? false)
_ARGUMENT_KEY_IMAGEURIS: _ARGUMENT_KEY_IMAGEURIS:
imageUris.map((Uri imageUri) => imageUri.toString()).toList(), imageUris?.map((Uri imageUri) => imageUri.toString()).toList(),
if (videoUri != null) _ARGUMENT_KEY_VIDEOURI: videoUri.toString(), if (videoUri != null) _ARGUMENT_KEY_VIDEOURI: videoUri.toString(),
}, },
); );
@ -211,11 +210,11 @@ class Tencent {
/// 分享 - 文本Android调用的是系统API故而不会有回调 /// 分享 - 文本Android调用的是系统API故而不会有回调
Future<void> shareText({ Future<void> shareText({
@required int scene, required int scene,
@required String summary, required String summary,
}) { }) {
assert(scene == TencentScene.SCENE_QQ); assert(scene == TencentScene.SCENE_QQ);
assert(summary?.isNotEmpty ?? false); assert(summary.isNotEmpty);
return _channel.invokeMethod<void>( return _channel.invokeMethod<void>(
_METHOD_SHARETEXT, _METHOD_SHARETEXT,
<String, dynamic>{ <String, dynamic>{
@ -227,13 +226,13 @@ class Tencent {
/// 分享 - 图片 /// 分享 - 图片
Future<void> shareImage({ Future<void> shareImage({
@required int scene, required int scene,
@required Uri imageUri, required Uri imageUri,
String appName, String? appName,
int extInt = TencentQZoneFlag.DEFAULT, int extInt = TencentQZoneFlag.DEFAULT,
}) { }) {
assert(scene == TencentScene.SCENE_QQ); assert(scene == TencentScene.SCENE_QQ);
assert(imageUri != null && imageUri.isScheme(_SCHEME_FILE)); assert(imageUri.isScheme(_SCHEME_FILE));
return _channel.invokeMethod<void>( return _channel.invokeMethod<void>(
_METHOD_SHAREIMAGE, _METHOD_SHAREIMAGE,
<String, dynamic>{ <String, dynamic>{
@ -247,19 +246,19 @@ class Tencent {
/// 分享 - 音乐 /// 分享 - 音乐
Future<void> shareMusic({ Future<void> shareMusic({
@required int scene, required int scene,
@required String title, required String title,
String summary, String? summary,
Uri imageUri, Uri? imageUri,
@required String musicUrl, required String musicUrl,
@required String targetUrl, required String targetUrl,
String appName, String? appName,
int extInt = TencentQZoneFlag.DEFAULT, int extInt = TencentQZoneFlag.DEFAULT,
}) { }) {
assert(scene == TencentScene.SCENE_QQ); assert(scene == TencentScene.SCENE_QQ);
assert(title?.isNotEmpty ?? false); assert(title.isNotEmpty);
assert(musicUrl?.isNotEmpty ?? false); assert(musicUrl.isNotEmpty);
assert(targetUrl?.isNotEmpty ?? false); assert(targetUrl.isNotEmpty);
return _channel.invokeMethod<void>( return _channel.invokeMethod<void>(
_METHOD_SHAREMUSIC, _METHOD_SHAREMUSIC,
<String, dynamic>{ <String, dynamic>{
@ -277,16 +276,16 @@ class Tencent {
/// 分享 - 网页 /// 分享 - 网页
Future<void> shareWebpage({ Future<void> shareWebpage({
@required int scene, required int scene,
@required String title, required String title,
String summary, String? summary,
Uri imageUri, Uri? imageUri,
@required String targetUrl, required String targetUrl,
String appName, String? appName,
int extInt = TencentQZoneFlag.DEFAULT, int extInt = TencentQZoneFlag.DEFAULT,
}) { }) {
assert(title?.isNotEmpty ?? false); assert(title.isNotEmpty);
assert(targetUrl?.isNotEmpty ?? false); assert(targetUrl.isNotEmpty);
return _channel.invokeMethod<void>( return _channel.invokeMethod<void>(
_METHOD_SHAREWEBPAGE, _METHOD_SHAREWEBPAGE,
<String, dynamic>{ <String, dynamic>{

View File

@ -7,14 +7,14 @@ packages:
name: _fe_analyzer_shared name: _fe_analyzer_shared
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "14.0.0" version: "18.0.0"
analyzer: analyzer:
dependency: transitive dependency: transitive
description: description:
name: analyzer name: analyzer
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.41.2" version: "1.2.0"
args: args:
dependency: transitive dependency: transitive
description: description:
@ -28,56 +28,56 @@ packages:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.5.0-nullsafety.1" version: "2.5.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0-nullsafety.1" version: "2.1.0"
build: build:
dependency: transitive dependency: transitive
description: description:
name: build name: build
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.6.1" version: "2.0.0"
build_config: build_config:
dependency: transitive dependency: transitive
description: description:
name: build_config name: build_config
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.4.5" version: "0.4.7"
build_daemon: build_daemon:
dependency: transitive dependency: transitive
description: description:
name: build_daemon name: build_daemon
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.6" version: "2.1.10"
build_resolvers: build_resolvers:
dependency: transitive dependency: transitive
description: description:
name: build_resolvers name: build_resolvers
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.5.2" version: "2.0.0"
build_runner: build_runner:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: build_runner name: build_runner
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.11.0" version: "1.12.2"
build_runner_core: build_runner_core:
dependency: transitive dependency: transitive
description: description:
name: build_runner_core name: build_runner_core
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "6.1.6" version: "6.1.12"
built_collection: built_collection:
dependency: transitive dependency: transitive
description: description:
@ -98,35 +98,35 @@ packages:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0-nullsafety.3" version: "1.1.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
checked_yaml: checked_yaml:
dependency: transitive dependency: transitive
description: description:
name: checked_yaml name: checked_yaml
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.4" version: "2.0.1"
cli_util: cli_util:
dependency: transitive dependency: transitive
description: description:
name: cli_util name: cli_util
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.2.0" version: "0.3.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0-nullsafety.1" version: "1.1.0"
code_builder: code_builder:
dependency: transitive dependency: transitive
description: description:
@ -140,49 +140,49 @@ packages:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.15.0-nullsafety.3" version: "1.15.0"
convert: convert:
dependency: transitive dependency: transitive
description: description:
name: convert name: convert
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.1" version: "3.0.0"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
name: crypto name: crypto
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.5" version: "3.0.0"
dart_style: dart_style:
dependency: transitive dependency: transitive
description: description:
name: dart_style name: dart_style
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.11" version: "1.3.14"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:
name: ffi name: ffi
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.1.3" version: "1.0.0"
file: file:
dependency: transitive dependency: transitive
description: description:
name: file name: file
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "5.2.1" version: "6.1.0"
fixnum: fixnum:
dependency: transitive dependency: transitive
description: description:
@ -206,14 +206,14 @@ packages:
name: glob name: glob
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0" version: "2.0.0"
graphs: graphs:
dependency: transitive dependency: transitive
description: description:
name: graphs name: graphs
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.2.0" version: "1.0.0"
http_multi_server: http_multi_server:
dependency: transitive dependency: transitive
description: description:
@ -228,13 +228,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.1.4" version: "3.1.4"
intl:
dependency: transitive
description:
name: intl
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.16.1"
io: io:
dependency: transitive dependency: transitive
description: description:
@ -255,35 +248,35 @@ packages:
name: json_annotation name: json_annotation
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.1.1" version: "4.0.0"
json_serializable: json_serializable:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: json_serializable name: json_serializable
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.5.1" version: "4.0.3"
logging: logging:
dependency: transitive dependency: transitive
description: description:
name: logging name: logging
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.11.4" version: "1.0.0"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.12.10-nullsafety.1" version: "0.12.10"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0-nullsafety.3" version: "1.3.0"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@ -291,125 +284,104 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.9.7" version: "0.9.7"
node_interop:
dependency: transitive
description:
name: node_interop
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.1"
node_io:
dependency: transitive
description:
name: node_io
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
okhttp_kit:
dependency: "direct dev"
description:
name: okhttp_kit
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.2"
package_config: package_config:
dependency: transitive dependency: transitive
description: description:
name: package_config name: package_config
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.9.3" version: "2.0.0"
path: path:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.0-nullsafety.1" version: "1.8.0"
path_provider: path_provider:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: path_provider name: path_provider
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.6.27" version: "2.0.1"
path_provider_linux: path_provider_linux:
dependency: transitive dependency: transitive
description: description:
name: path_provider_linux name: path_provider_linux
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.1+2" version: "2.0.0"
path_provider_macos: path_provider_macos:
dependency: transitive dependency: transitive
description: description:
name: path_provider_macos name: path_provider_macos
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.4+8" version: "2.0.0"
path_provider_platform_interface: path_provider_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: path_provider_platform_interface name: path_provider_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.4" version: "2.0.1"
path_provider_windows: path_provider_windows:
dependency: transitive dependency: transitive
description: description:
name: path_provider_windows name: path_provider_windows
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.4+3" version: "2.0.0"
pedantic: pedantic:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: pedantic name: pedantic
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.9.2" version: "1.11.0"
platform: platform:
dependency: transitive dependency: transitive
description: description:
name: platform name: platform
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.2.1" version: "3.0.0"
plugin_platform_interface: plugin_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: plugin_platform_interface name: plugin_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.3" version: "2.0.0"
pool: pool:
dependency: transitive dependency: transitive
description: description:
name: pool name: pool
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.4.0" version: "1.5.0"
process: process:
dependency: transitive dependency: transitive
description: description:
name: process name: process
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.0.13" version: "4.1.0"
pub_semver: pub_semver:
dependency: transitive dependency: transitive
description: description:
name: pub_semver name: pub_semver
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.4.4" version: "2.0.0"
pubspec_parse: pubspec_parse:
dependency: transitive dependency: transitive
description: description:
name: pubspec_parse name: pubspec_parse
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.1.7" version: "1.0.0"
quiver: quiver:
dependency: transitive dependency: transitive
description: description:
@ -442,56 +414,56 @@ packages:
name: source_gen name: source_gen
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.9.10+1" version: "0.9.10+4"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.0-nullsafety.2" version: "1.8.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.10.0-nullsafety.1" version: "1.10.0"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0-nullsafety.1" version: "2.1.0"
stream_transform: stream_transform:
dependency: transitive dependency: transitive
description: description:
name: stream_transform name: stream_transform
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0" version: "2.0.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0-nullsafety.1" version: "1.1.0"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.2.19-nullsafety.2" version: "0.2.19"
timing: timing:
dependency: transitive dependency: transitive
description: description:
@ -505,21 +477,21 @@ packages:
name: typed_data name: typed_data
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0-nullsafety.3" version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0-nullsafety.3" version: "2.1.0"
watcher: watcher:
dependency: transitive dependency: transitive
description: description:
name: watcher name: watcher
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.9.7+15" version: "1.0.0"
web_socket_channel: web_socket_channel:
dependency: transitive dependency: transitive
description: description:
@ -533,21 +505,21 @@ packages:
name: win32 name: win32
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.7.4+1" version: "2.0.4"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
name: xdg_directories name: xdg_directories
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.1.2" version: "0.2.0"
yaml: yaml:
dependency: transitive dependency: transitive
description: description:
name: yaml name: yaml
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.2.1" version: "3.1.0"
sdks: sdks:
dart: ">=2.10.0 <2.11.0" dart: ">=2.12.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0" flutter: ">=1.20.0"

View File

@ -5,28 +5,22 @@ version: 2.0.1
homepage: https://github.com/v7lin/fake_tencent homepage: https://github.com/v7lin/fake_tencent
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.10.0" flutter: ">=1.10.0"
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
json_annotation: ^4.0.0
json_annotation: '>=2.0.0 <4.0.0'
dev_dependencies: dev_dependencies:
build_runner: ^1.12.2
flutter_test: flutter_test:
sdk: flutter sdk: flutter
json_serializable: ^4.0.3
path: ^1.6.4 path: ^1.8.0
path_provider: ^1.4.0 path_provider: ^2.0.1
pedantic: ^1.11.0
okhttp_kit: ^1.0.0
pedantic:
build_runner:
json_serializable:
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # following page: https://dart.dev/tools/pub/pubspec

View File

@ -26,7 +26,7 @@ void main() {
channel.name, channel.name,
channel.codec.encodeMethodCall( channel.codec.encodeMethodCall(
MethodCall('onLoginResp', json.decode('{"ret":-2}'))), MethodCall('onLoginResp', json.decode('{"ret":-2}'))),
(ByteData data) { (ByteData? data) {
// mock success // mock success
}, },
)); ));
@ -42,7 +42,7 @@ void main() {
channel.name, channel.name,
channel.codec.encodeMethodCall( channel.codec.encodeMethodCall(
MethodCall('onShareResp', json.decode('{"ret":0}'))), MethodCall('onShareResp', json.decode('{"ret":0}'))),
(ByteData data) { (ByteData? data) {
// mock success // mock success
}, },
)); ));