格式化

This commit is contained in:
v7lin
2022-05-16 18:54:52 +08:00
parent 27f5f8cc7d
commit 39a9a43d8d
7 changed files with 76 additions and 58 deletions

View File

@ -70,6 +70,13 @@ class _HomeState extends State<Home> {
),
body: ListView(
children: <Widget>[
ListTile(
title: Text('3.1.0 之后的版本请先获取权限'),
onTap: () async {
await Tencent.setIsPermissionGranted(granted: true);
_showTips('授权', '已授权获取设备信息/同意隐私协议');
},
),
ListTile(
title: Text('注册APP'),
onTap: () async {
@ -80,17 +87,11 @@ class _HomeState extends State<Home> {
ListTile(
title: Text('环境检查'),
onTap: () async {
final String content = 'QQ install: ${await Tencent.isQQInstalled()}\nTIM install: ${await Tencent.isTIMInstalled()}';
final String content =
'QQ install: ${await Tencent.isQQInstalled()}\nTIM install: ${await Tencent.isTIMInstalled()}';
_showTips('环境检查', content);
},
),
ListTile(
title: Text('3.1.0 之后的版本请先获取权限'),
onTap: () async {
await Tencent.setIsPermissionGranted(granted: true);
_showTips('授权', '已授权获取设备信息/同意隐私协议');
},
),
ListTile(
title: Text('登录'),
onTap: () {
@ -102,14 +103,17 @@ class _HomeState extends State<Home> {
ListTile(
title: Text('获取用户信息'),
onTap: () async {
if ((_loginResp?.isSuccessful ?? false) && !(_loginResp!.isExpired ?? true)) {
final TencentUserInfoResp userInfo = await TencentApi.getUserInfo(
if ((_loginResp?.isSuccessful ?? false) &&
!(_loginResp!.isExpired ?? true)) {
final TencentUserInfoResp userInfo =
await TencentApi.getUserInfo(
appId: _TENCENT_APPID,
openid: _loginResp!.openid!,
accessToken: _loginResp!.accessToken!,
);
if (userInfo.isSuccessful) {
_showTips('用户信息', '${userInfo.nickname} - ${userInfo.gender} - ${userInfo.genderType}');
_showTips('用户信息',
'${userInfo.nickname} - ${userInfo.gender} - ${userInfo.genderType}');
} else {
_showTips('用户信息', '${userInfo.ret} - ${userInfo.msg}');
}
@ -119,14 +123,17 @@ class _HomeState extends State<Home> {
ListTile(
title: Text('获取UnionID'),
onTap: () async {
if ((_loginResp?.isSuccessful ?? false) && !(_loginResp!.isExpired ?? true)) {
if ((_loginResp?.isSuccessful ?? false) &&
!(_loginResp!.isExpired ?? true)) {
final TencentUnionidResp unionid = await TencentApi.getUnionId(
accessToken: _loginResp!.accessToken!,
);
if (unionid.isSuccessful) {
_showTips('UnionID', '${unionid.clientId} - ${unionid.openid} - ${unionid.unionid}');
_showTips('UnionID',
'${unionid.clientId} - ${unionid.openid} - ${unionid.unionid}');
} else {
_showTips('UnionID', '${unionid.error} - ${unionid.errorDescription}');
_showTips('UnionID',
'${unionid.error} - ${unionid.errorDescription}');
}
}
},
@ -152,7 +159,8 @@ class _HomeState extends State<Home> {
ListTile(
title: Text('图片分享'),
onTap: () async {
final File file = await DefaultCacheManager().getSingleFile('https://www.baidu.com/img/bd_logo1.png?where=super');
final File file = await DefaultCacheManager().getSingleFile(
'https://www.baidu.com/img/bd_logo1.png?where=super');
await Tencent.shareImage(
scene: TencentScene.SCENE_QQ,
imageUri: Uri.file(file.path),