去除 new
This commit is contained in:
parent
733366e948
commit
5c83b3f773
@ -28,4 +28,5 @@ linter:
|
|||||||
- constant_identifier_names
|
- constant_identifier_names
|
||||||
- one_member_abstracts
|
- one_member_abstracts
|
||||||
- slash_for_doc_comments
|
- slash_for_doc_comments
|
||||||
- sort_constructors_first
|
- sort_constructors_first
|
||||||
|
- unnecessary_new
|
@ -17,7 +17,7 @@ void main() {
|
|||||||
|
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
SystemUiOverlayStyle systemUiOverlayStyle =
|
SystemUiOverlayStyle systemUiOverlayStyle =
|
||||||
const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
|
const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
|
||||||
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
|
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -25,17 +25,17 @@ void main() {
|
|||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
FakeWeibo weibo = new FakeWeibo(
|
FakeWeibo weibo = FakeWeibo(
|
||||||
appKey: _weiboAppKey,
|
appKey: _weiboAppKey,
|
||||||
scope: [
|
scope: [
|
||||||
FakeWeiboScope.ALL,
|
FakeWeiboScope.ALL,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
weibo.registerApp();
|
weibo.registerApp();
|
||||||
return new FakeWeiboProvider(
|
return FakeWeiboProvider(
|
||||||
weibo: weibo,
|
weibo: weibo,
|
||||||
child: new MaterialApp(
|
child: MaterialApp(
|
||||||
home: new Home(
|
home: Home(
|
||||||
weibo: weibo,
|
weibo: weibo,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -50,7 +50,7 @@ class Home extends StatefulWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() {
|
State<StatefulWidget> createState() {
|
||||||
return new _HomeState();
|
return _HomeState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,67 +91,73 @@ class _HomeState extends State<Home> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return new Scaffold(
|
return Scaffold(
|
||||||
appBar: new AppBar(
|
appBar: AppBar(
|
||||||
title: new Text('Fake Weibo Demo'),
|
title: Text('Fake Weibo Demo'),
|
||||||
),
|
),
|
||||||
body: new ListView(
|
body: ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new ListTile(
|
ListTile(
|
||||||
title: new Text('环境检查'),
|
title: Text('环境检查'),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
String content =
|
String content =
|
||||||
'weibo: ${await widget.weibo.isWeiboInstalled()}';
|
'weibo: ${await widget.weibo.isWeiboInstalled()}';
|
||||||
_showTips('环境检查', content);
|
_showTips('环境检查', content);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
new ListTile(
|
ListTile(
|
||||||
title: new Text('登录'),
|
title: Text('登录'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
widget.weibo.auth();
|
widget.weibo.auth();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
new ListTile(
|
ListTile(
|
||||||
title: new Text('用户信息'),
|
title: Text('用户信息'),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
if (_authResp != null &&
|
if (_authResp != null &&
|
||||||
_authResp.errorCode == FakeWeiboErrorCode.SUCCESS) {
|
_authResp.errorCode == FakeWeiboErrorCode.SUCCESS) {
|
||||||
FakeWeiboApiUserResp userResp = await widget.weibo
|
FakeWeiboApiUserResp userResp = await widget.weibo.getUserInfo(
|
||||||
.getUserInfo(appkey: _weiboAppKey, userId: _authResp.userId, accessToken: _authResp.accessToken);
|
appkey: _weiboAppKey,
|
||||||
if (userResp != null && userResp.errorCode == FakeWeiboApiBaseResp.ERROR_CODE_SUCCESS) {
|
userId: _authResp.userId,
|
||||||
_showTips('用户信息', '${userResp.screenName}\n${userResp.description}\n${userResp.location}\n${userResp.profileImageUrl}');
|
accessToken: _authResp.accessToken);
|
||||||
|
if (userResp != null &&
|
||||||
|
userResp.errorCode ==
|
||||||
|
FakeWeiboApiBaseResp.ERROR_CODE_SUCCESS) {
|
||||||
|
_showTips('用户信息',
|
||||||
|
'${userResp.screenName}\n${userResp.description}\n${userResp.location}\n${userResp.profileImageUrl}');
|
||||||
} else {
|
} else {
|
||||||
_showTips('用户信息', '获取用户信息失败\n${userResp.errorCode}:${userResp.error}');
|
_showTips('用户信息',
|
||||||
|
'获取用户信息失败\n${userResp.errorCode}:${userResp.error}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
new ListTile(
|
ListTile(
|
||||||
title: new Text('文字分享'),
|
title: Text('文字分享'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
widget.weibo.shareText(
|
widget.weibo.shareText(
|
||||||
text: 'Share Text',
|
text: 'Share Text',
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
new ListTile(
|
ListTile(
|
||||||
title: new Text('图片分享'),
|
title: Text('图片分享'),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
AssetImage image = new AssetImage('images/icon/timg.jpeg');
|
AssetImage image = AssetImage('images/icon/timg.jpeg');
|
||||||
AssetBundleImageKey key =
|
AssetBundleImageKey key =
|
||||||
await image.obtainKey(createLocalImageConfiguration(context));
|
await image.obtainKey(createLocalImageConfiguration(context));
|
||||||
ByteData imageData = await key.bundle.load(key.name);
|
ByteData imageData = await key.bundle.load(key.name);
|
||||||
await widget.weibo.shareImage(
|
await widget.weibo.shareImage(
|
||||||
imageData: imageData.buffer.asUint8List(),
|
imageData: imageData.buffer.asUint8List(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
new ListTile(
|
ListTile(
|
||||||
title: new Text('网页分享'),
|
title: Text('网页分享'),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
AssetImage image = new AssetImage('images/icon/ic_launcher.png');
|
AssetImage image = AssetImage('images/icon/ic_launcher.png');
|
||||||
AssetBundleImageKey key =
|
AssetBundleImageKey key =
|
||||||
await image.obtainKey(createLocalImageConfiguration(context));
|
await image.obtainKey(createLocalImageConfiguration(context));
|
||||||
ByteData thumbData = await key.bundle.load(key.name);
|
ByteData thumbData = await key.bundle.load(key.name);
|
||||||
await widget.weibo.shareWebpage(
|
await widget.weibo.shareWebpage(
|
||||||
title: 'title',
|
title: 'title',
|
||||||
@ -170,9 +176,9 @@ class _HomeState extends State<Home> {
|
|||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return new AlertDialog(
|
return AlertDialog(
|
||||||
title: new Text(title),
|
title: Text(title),
|
||||||
content: new Text(content),
|
content: Text(content),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user