From 5c83b3f773482e3fe4eb11fa60c8bec1d1f8c81b Mon Sep 17 00:00:00 2001 From: v7lin Date: Tue, 5 Mar 2019 12:24:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=20new?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/analysis_options.yaml | 3 +- example/lib/main.dart | 74 +++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index c4c4b52..c7746e6 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -28,4 +28,5 @@ linter: - constant_identifier_names - one_member_abstracts - slash_for_doc_comments - - sort_constructors_first \ No newline at end of file + - sort_constructors_first + - unnecessary_new \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index ed30a52..58834fd 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -17,7 +17,7 @@ void main() { if (Platform.isAndroid) { SystemUiOverlayStyle systemUiOverlayStyle = - const SystemUiOverlayStyle(statusBarColor: Colors.transparent); + const SystemUiOverlayStyle(statusBarColor: Colors.transparent); SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle); } } @@ -25,17 +25,17 @@ void main() { class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - FakeWeibo weibo = new FakeWeibo( + FakeWeibo weibo = FakeWeibo( appKey: _weiboAppKey, scope: [ FakeWeiboScope.ALL, ], ); weibo.registerApp(); - return new FakeWeiboProvider( + return FakeWeiboProvider( weibo: weibo, - child: new MaterialApp( - home: new Home( + child: MaterialApp( + home: Home( weibo: weibo, ), ), @@ -50,7 +50,7 @@ class Home extends StatefulWidget { @override State createState() { - return new _HomeState(); + return _HomeState(); } } @@ -91,67 +91,73 @@ class _HomeState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( - title: new Text('Fake Weibo Demo'), + return Scaffold( + appBar: AppBar( + title: Text('Fake Weibo Demo'), ), - body: new ListView( + body: ListView( children: [ - new ListTile( - title: new Text('环境检查'), + ListTile( + title: Text('环境检查'), onTap: () async { String content = 'weibo: ${await widget.weibo.isWeiboInstalled()}'; _showTips('环境检查', content); }, ), - new ListTile( - title: new Text('登录'), + ListTile( + title: Text('登录'), onTap: () { widget.weibo.auth(); }, ), - new ListTile( - title: new Text('用户信息'), + ListTile( + title: Text('用户信息'), onTap: () async { if (_authResp != null && _authResp.errorCode == FakeWeiboErrorCode.SUCCESS) { - FakeWeiboApiUserResp userResp = await widget.weibo - .getUserInfo(appkey: _weiboAppKey, userId: _authResp.userId, accessToken: _authResp.accessToken); - if (userResp != null && userResp.errorCode == FakeWeiboApiBaseResp.ERROR_CODE_SUCCESS) { - _showTips('用户信息', '${userResp.screenName}\n${userResp.description}\n${userResp.location}\n${userResp.profileImageUrl}'); + FakeWeiboApiUserResp userResp = await widget.weibo.getUserInfo( + appkey: _weiboAppKey, + userId: _authResp.userId, + 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 { - _showTips('用户信息', '获取用户信息失败\n${userResp.errorCode}:${userResp.error}'); + _showTips('用户信息', + '获取用户信息失败\n${userResp.errorCode}:${userResp.error}'); } } }, ), - new ListTile( - title: new Text('文字分享'), + ListTile( + title: Text('文字分享'), onTap: () { widget.weibo.shareText( text: 'Share Text', ); }, ), - new ListTile( - title: new Text('图片分享'), + ListTile( + title: Text('图片分享'), onTap: () async { - AssetImage image = new AssetImage('images/icon/timg.jpeg'); + AssetImage image = AssetImage('images/icon/timg.jpeg'); AssetBundleImageKey key = - await image.obtainKey(createLocalImageConfiguration(context)); + await image.obtainKey(createLocalImageConfiguration(context)); ByteData imageData = await key.bundle.load(key.name); await widget.weibo.shareImage( imageData: imageData.buffer.asUint8List(), ); }, ), - new ListTile( - title: new Text('网页分享'), + ListTile( + title: Text('网页分享'), onTap: () async { - AssetImage image = new AssetImage('images/icon/ic_launcher.png'); + AssetImage image = AssetImage('images/icon/ic_launcher.png'); AssetBundleImageKey key = - await image.obtainKey(createLocalImageConfiguration(context)); + await image.obtainKey(createLocalImageConfiguration(context)); ByteData thumbData = await key.bundle.load(key.name); await widget.weibo.shareWebpage( title: 'title', @@ -170,9 +176,9 @@ class _HomeState extends State { showDialog( context: context, builder: (BuildContext context) { - return new AlertDialog( - title: new Text(title), - content: new Text(content), + return AlertDialog( + title: Text(title), + content: Text(content), ); }, );