diff --git a/lib/api/qiniu_api.dart b/lib/api/qiniu_api.dart index e6b6ef3..ef94add 100644 --- a/lib/api/qiniu_api.dart +++ b/lib/api/qiniu_api.dart @@ -144,7 +144,10 @@ class QiniuApi { /// 七牛管理验签拦截器 class QiniuInterceptor extends InterceptorsWrapper { @override - Future onRequest(RequestOptions options) async { + Future onRequest( + RequestOptions options, + RequestInterceptorHandler handler, + ) async { if (options.path.contains(QiniuApi.BASE_URL)) { String ak = '${options.extra[QiniuApi.accessKey]}'; String sk = '${options.extra[QiniuApi.secretKey]}'; diff --git a/lib/api/tcyun_api.dart b/lib/api/tcyun_api.dart index 7182bb3..6630dea 100644 --- a/lib/api/tcyun_api.dart +++ b/lib/api/tcyun_api.dart @@ -88,7 +88,10 @@ class TcyunApi { /// TcYun验签拦截器 class TcyunInterceptor extends InterceptorsWrapper { @override - Future onRequest(RequestOptions options) async { + Future onRequest( + RequestOptions options, + RequestInterceptorHandler handler, + ) async { if (options.path.contains(TcyunApi.BASE_URL)) { /// 生成 KeyTime var keytime = TcyunApi.buildKeyTime(); diff --git a/lib/api/upyun_api.dart b/lib/api/upyun_api.dart index 53a545c..74b0518 100644 --- a/lib/api/upyun_api.dart +++ b/lib/api/upyun_api.dart @@ -68,7 +68,10 @@ class UpyunApi { class UpyunInterceptor extends InterceptorsWrapper { @override - Future onRequest(RequestOptions options) async { + Future onRequest( + RequestOptions options, + RequestInterceptorHandler handler, + ) async { if (options.path.contains(UpyunApi.BASE_URL.replaceFirst('http://', ''))) { /// 请求方式,如:GET、POST、PUT、HEAD 等 String method = options.method.toUpperCase(); diff --git a/lib/utils/image_preview.dart b/lib/utils/image_preview.dart index 12c11fc..a3a720b 100644 --- a/lib/utils/image_preview.dart +++ b/lib/utils/image_preview.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'dart:math'; import 'package:extended_image/extended_image.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_picgo/model/uploaded.dart'; @@ -17,8 +18,8 @@ class ImagePreviewUtils { Navigator.push( context, Platform.isAndroid - ? TransparentMaterialPageRoute(builder: (_) => page) - : TransparentCupertinoPageRoute(builder: (_) => page), + ? MaterialPageRoute(builder: (_) => page) + : CupertinoPageRoute(builder: (_) => page), ); } @@ -30,8 +31,8 @@ class ImagePreviewUtils { Navigator.push( context, Platform.isAndroid - ? TransparentMaterialPageRoute(builder: (_) => page) - : TransparentCupertinoPageRoute(builder: (_) => page)); + ? MaterialPageRoute(builder: (_) => page) + : CupertinoPageRoute(builder: (_) => page)); } } diff --git a/lib/utils/permission.dart b/lib/utils/permission.dart index 0ad40ca..4fc1a30 100644 --- a/lib/utils/permission.dart +++ b/lib/utils/permission.dart @@ -21,7 +21,7 @@ class PermissionUtils { title: Text('警告'), content: Text(text), actions: [ - FlatButton( + TextButton( child: Text('去设置'), onPressed: () { openAppSettings(); diff --git a/lib/utils/strategy/impl/gitee_image_upload.dart b/lib/utils/strategy/impl/gitee_image_upload.dart index 2ea8832..29527f5 100644 --- a/lib/utils/strategy/impl/gitee_image_upload.dart +++ b/lib/utils/strategy/impl/gitee_image_upload.dart @@ -77,7 +77,7 @@ class GiteeImageUpload implements ImageUploadStrategy { await ImageUploadUtils.saveUploadedItem(uploadedItem); return uploadedItem; } on DioError catch (e) { - if (e.type == DioErrorType.RESPONSE && + if (e.type == DioErrorType.response && e.error.toString().indexOf('400') > 0) { throw GiteeError(error: '文件已存在!'); } else { diff --git a/lib/utils/strategy/impl/github_image_upload.dart b/lib/utils/strategy/impl/github_image_upload.dart index f57d3c9..e39384d 100644 --- a/lib/utils/strategy/impl/github_image_upload.dart +++ b/lib/utils/strategy/impl/github_image_upload.dart @@ -64,7 +64,7 @@ class GithubImageUpload implements ImageUploadStrategy { throw GithubError(error: '读取配置文件错误!请重试'); } } on DioError catch (e) { - if (e.type == DioErrorType.RESPONSE && + if (e.type == DioErrorType.response && e.error.toString().indexOf('422') > 0) { throw GithubError(error: '文件已存在!'); } else { diff --git a/lib/utils/strategy/impl/qiniu_image_upload.dart b/lib/utils/strategy/impl/qiniu_image_upload.dart index 49d2eda..e558a46 100644 --- a/lib/utils/strategy/impl/qiniu_image_upload.dart +++ b/lib/utils/strategy/impl/qiniu_image_upload.dart @@ -31,16 +31,16 @@ class QiniuImageUpload extends ImageUploadStrategy { } return uploaded; } on DioError catch (e) { - if (e.type == DioErrorType.RESPONSE && + if (e.type == DioErrorType.response && e.error.toString().indexOf('400') > 0) { throw QiniuError(error: '400 请求报文格式错误'); - } else if (e.type == DioErrorType.RESPONSE && + } else if (e.type == DioErrorType.response && e.error.toString().indexOf('401') > 0) { throw QiniuError(error: '401 管理凭证无效'); - } else if (e.type == DioErrorType.RESPONSE && + } else if (e.type == DioErrorType.response && e.error.toString().indexOf('599') > 0) { throw QiniuError(error: '599 服务端操作失败'); - } else if (e.type == DioErrorType.RESPONSE && + } else if (e.type == DioErrorType.response && e.error.toString().indexOf('612') > 0) { throw QiniuError(error: '612 待删除资源不存在'); } else { @@ -88,16 +88,16 @@ class QiniuImageUpload extends ImageUploadStrategy { await ImageUploadUtils.saveUploadedItem(uploadedItem); return uploadedItem; } on DioError catch (e) { - if (e.type == DioErrorType.RESPONSE && + if (e.type == DioErrorType.response && e.error.toString().indexOf('400') > 0) { throw QiniuError(error: '400 请求报文格式错误'); - } else if (e.type == DioErrorType.RESPONSE && + } else if (e.type == DioErrorType.response && e.error.toString().indexOf('401') > 0) { throw QiniuError(error: '401 管理凭证无效'); - } else if (e.type == DioErrorType.RESPONSE && + } else if (e.type == DioErrorType.response && e.error.toString().indexOf('599') > 0) { throw QiniuError(error: '599 服务端操作失败'); - } else if (e.type == DioErrorType.RESPONSE && + } else if (e.type == DioErrorType.response && e.error.toString().indexOf('612') > 0) { throw QiniuError(error: '612 待删除资源不存在'); } else { diff --git a/lib/views/404.dart b/lib/views/404.dart index 4fd439d..626bc10 100644 --- a/lib/views/404.dart +++ b/lib/views/404.dart @@ -10,8 +10,10 @@ class PageNotFound extends StatelessWidget { ), body: Container( child: Center( - child: OutlineButton( - color: Colors.blue, + child: OutlinedButton( + style: ButtonStyle( + side: + MaterialStateProperty.all(BorderSide(color: Colors.blue))), child: Text('关闭'), onPressed: () { Application.router.pop(context); diff --git a/lib/views/album_page/album_page.dart b/lib/views/album_page/album_page.dart index eb46226..d7720e0 100644 --- a/lib/views/album_page/album_page.dart +++ b/lib/views/album_page/album_page.dart @@ -215,7 +215,7 @@ class _AlbumPageState extends State implements AlbumPageContract { title: Text('确定删除吗'), content: Text('删除后无法恢复'), actions: [ - FlatButton( + TextButton( child: Text('确定'), onPressed: () { Navigator.pop(context); diff --git a/lib/views/manage_page/gitee_page/gitee_repo_page.dart b/lib/views/manage_page/gitee_page/gitee_repo_page.dart index 24b6e09..e19c1be 100644 --- a/lib/views/manage_page/gitee_page/gitee_repo_page.dart +++ b/lib/views/manage_page/gitee_page/gitee_repo_page.dart @@ -92,9 +92,11 @@ class _GiteeRepoPageState extends BaseLoadingPageState child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - RaisedButton( - color: Theme.of(context).accentColor, - textColor: Colors.white, + ElevatedButton( + style: ButtonStyle( + foregroundColor: MaterialStateProperty.all(Colors.white), + backgroundColor: + MaterialStateProperty.all(Theme.of(context).accentColor)), child: Text('刷新'), onPressed: () { setState(() { @@ -164,7 +166,7 @@ class _GiteeRepoPageState extends BaseLoadingPageState title: Text('确定删除吗'), content: Text('删除后无法恢复'), actions: [ - FlatButton( + TextButton( child: Text('确定'), onPressed: () { Navigator.pop(context, true); diff --git a/lib/views/manage_page/github_page/github_repo_page.dart b/lib/views/manage_page/github_page/github_repo_page.dart index 040d791..42c05b2 100644 --- a/lib/views/manage_page/github_page/github_repo_page.dart +++ b/lib/views/manage_page/github_page/github_repo_page.dart @@ -92,9 +92,11 @@ class _GithubRepoPageState extends BaseLoadingPageState child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - RaisedButton( - color: Theme.of(context).accentColor, - textColor: Colors.white, + ElevatedButton( + style: ButtonStyle( + foregroundColor: MaterialStateProperty.all(Colors.white), + backgroundColor: + MaterialStateProperty.all(Theme.of(context).accentColor)), child: Text('刷新'), onPressed: () { setState(() { @@ -164,7 +166,7 @@ class _GithubRepoPageState extends BaseLoadingPageState title: Text('确定删除吗'), content: Text('删除后无法恢复'), actions: [ - FlatButton( + TextButton( child: Text('确定'), onPressed: () { Navigator.pop(context, true); diff --git a/lib/views/manage_page/lsky_page/lsky_repo_page.dart b/lib/views/manage_page/lsky_page/lsky_repo_page.dart index 9aca18d..679f969 100644 --- a/lib/views/manage_page/lsky_page/lsky_repo_page.dart +++ b/lib/views/manage_page/lsky_page/lsky_repo_page.dart @@ -47,9 +47,11 @@ class _LskyRepoPageState extends BaseLoadingPageState child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - RaisedButton( - color: Theme.of(context).accentColor, - textColor: Colors.white, + ElevatedButton( + style: ButtonStyle( + foregroundColor: MaterialStateProperty.all(Colors.white), + backgroundColor: + MaterialStateProperty.all(Theme.of(context).accentColor)), child: Text('刷新'), onPressed: () { setState(() { @@ -136,7 +138,7 @@ class _LskyRepoPageState extends BaseLoadingPageState title: Text('确定删除吗'), content: Text('删除后无法恢复'), actions: [ - FlatButton( + TextButton( child: Text('确定'), onPressed: () { Navigator.pop(context, true); diff --git a/lib/views/manage_page/qiniu_page/qiniu_repo_page.dart b/lib/views/manage_page/qiniu_page/qiniu_repo_page.dart index 23fd6c3..3276e43 100644 --- a/lib/views/manage_page/qiniu_page/qiniu_repo_page.dart +++ b/lib/views/manage_page/qiniu_page/qiniu_repo_page.dart @@ -52,9 +52,11 @@ class _QiniuRepoPageState extends BaseLoadingPageState child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - RaisedButton( - color: Theme.of(context).accentColor, - textColor: Colors.white, + ElevatedButton( + style: ButtonStyle( + foregroundColor: MaterialStateProperty.all(Colors.white), + backgroundColor: + MaterialStateProperty.all(Theme.of(context).accentColor)), child: Text('刷新'), onPressed: () { setState(() { @@ -121,7 +123,7 @@ class _QiniuRepoPageState extends BaseLoadingPageState title: Text('确定删除吗'), content: Text('删除后无法恢复'), actions: [ - FlatButton( + TextButton( child: Text('确定'), onPressed: () { Navigator.pop(context, true); diff --git a/lib/views/manage_page/smms_page/smms_repo_page.dart b/lib/views/manage_page/smms_page/smms_repo_page.dart index f1cb286..6c311d1 100644 --- a/lib/views/manage_page/smms_page/smms_repo_page.dart +++ b/lib/views/manage_page/smms_page/smms_repo_page.dart @@ -120,9 +120,11 @@ class _SMMSRepoPageState extends BaseLoadingPageState child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - RaisedButton( - color: Theme.of(context).accentColor, - textColor: Colors.white, + ElevatedButton( + style: ButtonStyle( + foregroundColor: MaterialStateProperty.all(Colors.white), + backgroundColor: + MaterialStateProperty.all(Theme.of(context).accentColor)), child: Text('刷新'), onPressed: () { setState(() { @@ -181,7 +183,7 @@ class _SMMSRepoPageState extends BaseLoadingPageState title: Text('确定删除吗'), content: Text('删除后无法恢复'), actions: [ - FlatButton( + TextButton( child: Text('确定'), onPressed: () { Navigator.pop(context, true); diff --git a/lib/views/pb_setting_page/base_pb_page_state.dart b/lib/views/pb_setting_page/base_pb_page_state.dart index b31e835..a29be9d 100644 --- a/lib/views/pb_setting_page/base_pb_page_state.dart +++ b/lib/views/pb_setting_page/base_pb_page_state.dart @@ -50,9 +50,12 @@ abstract class BasePBSettingPageState child: Row( children: [ Expanded( - child: RaisedButton( - color: Theme.of(context).accentColor, - textColor: Colors.white, + child: ElevatedButton( + style: ButtonStyle( + foregroundColor: + MaterialStateProperty.all(Colors.white), + backgroundColor: MaterialStateProperty.all( + Theme.of(context).accentColor)), child: Text('保存'), onPressed: () { if (validate) { @@ -63,9 +66,12 @@ abstract class BasePBSettingPageState ), SizedBox(width: 5.0), Expanded( - child: RaisedButton( - color: Colors.greenAccent, - textColor: Colors.white, + child: ElevatedButton( + style: ButtonStyle( + foregroundColor: + MaterialStateProperty.all(Colors.white), + backgroundColor: + MaterialStateProperty.all(Colors.greenAccent)), child: Text('设为默认图床'), onPressed: () { if (validate) { diff --git a/lib/views/pb_setting_page/pb_setting_page.dart b/lib/views/pb_setting_page/pb_setting_page.dart index 8ad1146..179b816 100644 --- a/lib/views/pb_setting_page/pb_setting_page.dart +++ b/lib/views/pb_setting_page/pb_setting_page.dart @@ -50,7 +50,7 @@ class _PBSettingPageState extends State '在PC端已经配置好的用户可以使用PicGo新版的生成图床配置二维码功能。\n\n' + '然后使用Flutter-PicGo直接扫描即可进行配置转换。'), actions: [ - FlatButton( + TextButton( child: Text('已了解,去扫描'), onPressed: () { Navigator.pop(context); diff --git a/lib/views/upload_page/handle_upload_page.dart b/lib/views/upload_page/handle_upload_page.dart index 682ecfd..b8693e8 100644 --- a/lib/views/upload_page/handle_upload_page.dart +++ b/lib/views/upload_page/handle_upload_page.dart @@ -154,7 +154,7 @@ class _HandleUploadPageState extends State { ), ), actions: [ - FlatButton( + TextButton( child: Text('确定'), onPressed: () { Navigator.pop(context); diff --git a/pubspec.yaml b/pubspec.yaml index 04feef3..ede1bb0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,23 +23,22 @@ environment: dependencies: flutter: sdk: flutter - shared_preferences: ^0.5.12+4 - dio: ^3.0.9 - package_info: ^0.4.1 + shared_preferences: ^2.0.5 + dio: ^4.0.0 + package_info: ^2.0.0 sqflite: ^1.3.2+1 - fluro: ^1.7.7 + fluro: ^2.0.3 toast: ^0.1.5 json_serializable: ^3.3.0 url_launcher: ^5.7.10 permission_handler: ^5.0.1 barcode_scan: ^3.0.1 - provider: ^4.1.3 - crypto: ^2.1.4 + provider: ^5.0.0 + crypto: ^3.0.1 flutter_local_notifications: ^3.0.1+4 - pull_to_refresh: ^1.6.2 - characters: ^1.0.0 - wechat_assets_picker: ^4.2.2 - extended_image: ^1.5.0 + pull_to_refresh: ^1.6.5 + wechat_assets_picker: ^5.1.3 + extended_image: ^4.0.1 # The following adds the Cupertino Icons font to your application. diff --git a/test/api/aliyun_api_test.dart b/test/api/aliyun_api_test.dart index e1aa74a..3d74543 100644 --- a/test/api/aliyun_api_test.dart +++ b/test/api/aliyun_api_test.dart @@ -17,14 +17,14 @@ main() { var sign = AliyunApi.buildSignature('LTAIsXml0iczvY0J', 'yw8eO9Fa9Py2GAPRGG8N3GPKCeKCXl', 'PUT', 'zjyzy', 'test.txt'); try { - Response res = await NetUtils.getInstance().put( + await NetUtils.getInstance().put( 'https://zjyzy.oss-cn-shenzhen.aliyuncs.com/test.txt', options: Options(headers: { 'Authorization': sign, 'Date': HttpDate.format(new DateTime.now()), }, contentType: 'application/x-www-form-urlencoded'), ); - } on DioError catch (e) {} + } on DioError catch (_) {} }); test('测试FormData提交图片', () async { @@ -43,7 +43,7 @@ main() { var sign = hmacsha1.convert(utf8.encode(originSign)); var encodeSign = base64.encode(sign.bytes); try { - Response res = await NetUtils.getInstance().post( + await NetUtils.getInstance().post( 'https://zjyzy.oss-cn-shenzhen.aliyuncs.com', data: FormData.fromMap({ 'key': 'logo.png', @@ -53,6 +53,6 @@ main() { 'file': await MultipartFile.fromFile(pathname, filename: 'logo.png') }), options: Options(contentType: Headers.formUrlEncodedContentType)); - } on DioError catch (e) {} + } on DioError catch (_) {} }); } diff --git a/test/api/qiniu_api_test.dart b/test/api/qiniu_api_test.dart index ec90fbb..b38add0 100644 --- a/test/api/qiniu_api_test.dart +++ b/test/api/qiniu_api_test.dart @@ -4,10 +4,8 @@ import 'package:flutter_test/flutter_test.dart'; main() { test('测试UpToken生成', () { String policy = QiniuApi.generatePutPolicy('image', 'test.png'); - var token = QiniuApi.generateUpToken( - 'CRd7Wa4PuSGvs4ArToPTLBMCigGGUY3sk3F8oc8W', - 'f2Jkrlyea5s8h8gLEToa9-k895GNM-BlmQ2RfxwU', - policy); + QiniuApi.generateUpToken('CRd7Wa4PuSGvs4ArToPTLBMCigGGUY3sk3F8oc8W', + 'f2Jkrlyea5s8h8gLEToa9-k895GNM-BlmQ2RfxwU', policy); }); test('测试AuthToken生成', () { diff --git a/test/api/tcyun_api_test.dart b/test/api/tcyun_api_test.dart index 7bd9249..a14e8b4 100644 --- a/test/api/tcyun_api_test.dart +++ b/test/api/tcyun_api_test.dart @@ -1,8 +1,5 @@ -import 'dart:io'; - import 'package:flutter_picgo/api/tcyun_api.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:path/path.dart' as path; main() { test('测试生成 KeyTime', () {}); @@ -22,11 +19,11 @@ main() { test('PostObjecy 提交', () async { try { - String pathname = path.joinAll( - [Directory.current.path, '..\\assets\\' 'images', 'logo.png']); - String keyTime = TcyunApi.buildKeyTime(); - String policy = TcyunApi.buildPolicy('ap-nanjing', 'logo.png', - 'AKIDvb0B9rqfeOr44kt2ar46rO2cwzl6JwUk', keyTime); + // String pathname = path.joinAll( + // [Directory.current.path, '..\\assets\\' 'images', 'logo.png']); + // String keyTime = TcyunApi.buildKeyTime(); + // String policy = TcyunApi.buildPolicy('ap-nanjing', 'logo.png', + // 'AKIDvb0B9rqfeOr44kt2ar46rO2cwzl6JwUk', keyTime); // TcyunApi.postObject( // 'test-1253954259', // 'ap-nanjing',