diff --git a/.vscode/settings.json b/.vscode/settings.json index 18e9d078..484de20d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,6 +4,7 @@ "editor.formatOnType": true }, "editor.codeActionsOnSave": { - "source.organizeImports": "explicit" + "source.organizeImports": "explicit", + // "source.fixAll": "explicit", } } \ No newline at end of file diff --git a/lib/common/widgets/video_popup_menu.dart b/lib/common/widgets/video_popup_menu.dart index ee4493c5..fe3cda74 100644 --- a/lib/common/widgets/video_popup_menu.dart +++ b/lib/common/widgets/video_popup_menu.dart @@ -59,7 +59,7 @@ class VideoCustomActions { '访问:${videoItem.owner.name}', 'visit', Icon(MdiIcons.accountCircleOutline, size: 16), - () async { + () { Get.toNamed('/member?mid=${videoItem.owner.mid}', arguments: { 'heroTag': '${videoItem.owner.mid}', }); @@ -108,7 +108,7 @@ class VideoCustomActions { ); } - await showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( @@ -166,7 +166,7 @@ class VideoCustomActions { }, ); } else { - await showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( @@ -227,8 +227,8 @@ class VideoCustomActions { }), if (videoItem is! SpaceArchiveItem) VideoCustomAction('拉黑:${videoItem.owner.name}', 'block', - Icon(MdiIcons.cancel, size: 16), () async { - await showDialog( + Icon(MdiIcons.cancel, size: 16), () { + showDialog( context: context, builder: (context) { return AlertDialog( diff --git a/lib/grpc/grpc_repo.dart b/lib/grpc/grpc_repo.dart index 468a453f..f10c9be8 100644 --- a/lib/grpc/grpc_repo.dart +++ b/lib/grpc/grpc_repo.dart @@ -211,24 +211,24 @@ class GrpcRepo { // static Future playerOnline({ // int aid = 0, // int cid = 0, - // }) async { - // return await _request( + // }) { + // return _request( // GrpcUrl.playerOnline, // PlayerOnlineReq(aid: Int64(aid), cid: Int64(cid), playOpen: true), // PlayerOnlineReply.fromBuffer, // onSuccess: (response) => response.totalNumberText); // } - // static Future popular(int idx) async { - // return await _request(GrpcUrl.popular, PopularResultReq(idx: Int64(idx)), + // static Future popular(int idx) { + // return _request(GrpcUrl.popular, PopularResultReq(idx: Int64(idx)), // PopularReply.fromBuffer, onSuccess: (response) { // response.items.retainWhere((item) => item.smallCoverV5.base.goto == 'av'); // return {'status': true, 'data': response.items}; // }); // } - // static Future replyInfo({required int rpid}) async { - // return await _request( + // static Future replyInfo({required int rpid}) { + // return _request( // GrpcUrl.replyInfo, // ReplyInfoReq(rpid: Int64(rpid)), // ReplyInfoReply.fromBuffer, @@ -239,8 +239,8 @@ class GrpcRepo { // static Future dynSpace({ // required int uid, // required int page, - // }) async { - // return await _request( + // }) { + // return _request( // GrpcUrl.dynSpace, // DynSpaceReq( // hostUid: Int64(uid), @@ -258,8 +258,8 @@ class GrpcRepo { required Mode mode, required String? offset, required Int64? cursorNext, - }) async { - return await _request( + }) { + return _request( GrpcUrl.mainList, MainListReq( oid: Int64(oid), @@ -282,8 +282,8 @@ class GrpcRepo { required int rpid, required Mode mode, required String? offset, - }) async { - return await _request( + }) { + return _request( GrpcUrl.detailList, DetailListReq( oid: Int64(oid), @@ -304,8 +304,8 @@ class GrpcRepo { required int root, required int dialog, required String? offset, - }) async { - return await _request( + }) { + return _request( GrpcUrl.dialogList, DialogListReq( oid: Int64(oid), @@ -318,8 +318,8 @@ class GrpcRepo { ); } - static Future dynRed() async { - return await _request( + static Future dynRed() { + return _request( GrpcUrl.dynRed, DynRedReq(tabOffset: [TabOffset(tab: 1)]), DynRedReply.fromBuffer, @@ -328,8 +328,8 @@ class GrpcRepo { } static Future dmSegMobile( - {required int cid, required int segmentIndex, int type = 1}) async { - return await _request( + {required int cid, required int segmentIndex, int type = 1}) { + return _request( GrpcUrl.dmSegMobile, DmSegMobileReq( oid: Int64(cid), @@ -345,9 +345,9 @@ class GrpcRepo { required int receiverId, required String content, MsgType msgType = MsgType.EN_MSG_TYPE_TEXT, - }) async { + }) { final devId = const Uuid().v4(); - return await _request( + return _request( GrpcUrl.sendMsg, ReqSendMsg( msg: Msg( @@ -366,16 +366,16 @@ class GrpcRepo { ); } - static Future shareList({int size = 10}) async { - return await _request( + static Future shareList({int size = 10}) { + return _request( GrpcUrl.shareList, ReqShareList(size: size), RspShareList.fromBuffer, ); } - static Future sessionMain({PbMap? offset}) async { - return await _request( + static Future sessionMain({PbMap? offset}) { + return _request( GrpcUrl.sessionMain, SessionMainReq( paginationParams: PaginationParams(offsets: offset), @@ -387,8 +387,8 @@ class GrpcRepo { static Future clearUnread({ SessionPageType? pageType, SessionId? sessionId, - }) async { - return await _request( + }) { + return _request( GrpcUrl.clearUnread, ClearUnreadReq( pageType: pageType, diff --git a/lib/http/init.dart b/lib/http/init.dart index d476856a..7558a607 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -32,7 +32,7 @@ class Request { static Future setCookie() async { accountManager = AccountManager(); dio.interceptors.add(accountManager); - await Accounts.refresh(); + Accounts.refresh(); final List cookies = Accounts.main.cookieJar.toList(); final webManager = web.CookieManager(); await Future.wait(cookies.map((item) => webManager.setCookie( diff --git a/lib/pages/about/view.dart b/lib/pages/about/view.dart index e3df66cf..9f72987f 100644 --- a/lib/pages/about/view.dart +++ b/lib/pages/about/view.dart @@ -229,7 +229,7 @@ Commit Hash: ${BuildConfig.commitHash}''', children: [ ListTile( title: const Text('导出'), - onTap: () async { + onTap: () { Get.back(); String res = jsonEncode(Accounts.account.toMap()); Utils.copyText(res); @@ -246,7 +246,7 @@ Commit Hash: ${BuildConfig.commitHash}''', return; } if (!context.mounted) return; - await showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( @@ -312,9 +312,9 @@ Commit Hash: ${BuildConfig.commitHash}''', children: [ ListTile( title: const Text('导出设置至剪贴板'), - onTap: () async { + onTap: () { Get.back(); - String data = await GStorage.exportAllSettings(); + String data = GStorage.exportAllSettings(); Utils.copyText(data); }, ), diff --git a/lib/pages/article/view.dart b/lib/pages/article/view.dart index 74956f02..567bccfc 100644 --- a/lib/pages/article/view.dart +++ b/lib/pages/article/view.dart @@ -308,9 +308,7 @@ class _ArticlePageState extends State key: _key, backgroundColor: Colors.transparent, body: refreshIndicator( - onRefresh: () async { - await _articleCtr.onRefresh(); - }, + onRefresh: _articleCtr.onRefresh, child: Padding( padding: EdgeInsets.only(right: padding / 4), child: CustomScrollView( @@ -655,11 +653,11 @@ class _ArticlePageState extends State min: 1, max: 100, value: _ratio.first, - onChanged: (value) async { + onChanged: (value) { if (value >= 10 && value <= 90) { _ratio[0] = value; _ratio[1] = 100 - value; - await GStorage.setting.put( + GStorage.setting.put( SettingBoxKey.dynamicDetailRatio, _ratio, ); diff --git a/lib/pages/bangumi/view.dart b/lib/pages/bangumi/view.dart index e3385404..061548c0 100644 --- a/lib/pages/bangumi/view.dart +++ b/lib/pages/bangumi/view.dart @@ -47,9 +47,7 @@ class _BangumiPageState extends CommonPageState super.build(context); final ThemeData theme = Theme.of(context); return refreshIndicator( - onRefresh: () async { - await controller.onRefresh(); - }, + onRefresh: controller.onRefresh, child: CustomScrollView( controller: controller.scrollController, physics: const AlwaysScrollableScrollPhysics(), diff --git a/lib/pages/bangumi/widgets/bangumi_card_v.dart b/lib/pages/bangumi/widgets/bangumi_card_v.dart index a3bd831f..8cf8fb92 100644 --- a/lib/pages/bangumi/widgets/bangumi_card_v.dart +++ b/lib/pages/bangumi/widgets/bangumi_card_v.dart @@ -26,7 +26,7 @@ class BangumiCardV extends StatelessWidget { title: bangumiItem.title, cover: bangumiItem.cover, ), - onTap: () async { + onTap: () { final int seasonId = bangumiItem.seasonId; PageUtils.viewBangumi(seasonId: seasonId); }, diff --git a/lib/pages/bangumi/widgets/bangumi_card_v_member_home.dart b/lib/pages/bangumi/widgets/bangumi_card_v_member_home.dart index 997ee859..2a286bd8 100644 --- a/lib/pages/bangumi/widgets/bangumi_card_v_member_home.dart +++ b/lib/pages/bangumi/widgets/bangumi_card_v_member_home.dart @@ -21,7 +21,7 @@ class BangumiCardVMemberHome extends StatelessWidget { clipBehavior: Clip.hardEdge, margin: EdgeInsets.zero, child: InkWell( - onTap: () async { + onTap: () { final int seasonId = int.tryParse(bangumiItem.param ?? '') ?? -1; PageUtils.viewBangumi(seasonId: seasonId); }, diff --git a/lib/pages/bangumi/widgets/bangumi_card_v_search.dart b/lib/pages/bangumi/widgets/bangumi_card_v_search.dart index 78fded7c..6a7a7f9b 100644 --- a/lib/pages/bangumi/widgets/bangumi_card_v_search.dart +++ b/lib/pages/bangumi/widgets/bangumi_card_v_search.dart @@ -24,7 +24,7 @@ class BangumiCardVSearch extends StatelessWidget { title: item.title?.map((e) => e['text']).join(), cover: item.cover, ), - onTap: () async { + onTap: () { PageUtils.viewBangumi(seasonId: item.seasonId); }, child: Column( diff --git a/lib/pages/bangumi/widgets/bangumi_card_v_timeline.dart b/lib/pages/bangumi/widgets/bangumi_card_v_timeline.dart index 2b38e95f..45019f70 100644 --- a/lib/pages/bangumi/widgets/bangumi_card_v_timeline.dart +++ b/lib/pages/bangumi/widgets/bangumi_card_v_timeline.dart @@ -25,7 +25,7 @@ class BangumiCardVTimeline extends StatelessWidget { title: item.title, cover: item.cover, ), - onTap: () async { + onTap: () { PageUtils.viewBangumi(seasonId: item.seasonId, epId: item.episodeId); }, child: Column( diff --git a/lib/pages/blacklist/controller.dart b/lib/pages/blacklist/controller.dart index 896b44ce..618b7c0d 100644 --- a/lib/pages/blacklist/controller.dart +++ b/lib/pages/blacklist/controller.dart @@ -38,7 +38,7 @@ class BlackListController return false; } - Future onRemove(BuildContext context, int index, name, mid) async { + void onRemove(BuildContext context, int index, name, mid) { showConfirmDialog( context: context, title: '确定将 $name 移出黑名单?', diff --git a/lib/pages/blacklist/view.dart b/lib/pages/blacklist/view.dart index 46c50b9c..20444d04 100644 --- a/lib/pages/blacklist/view.dart +++ b/lib/pages/blacklist/view.dart @@ -40,7 +40,7 @@ class _BlackListPageState extends State { ), ), body: refreshIndicator( - onRefresh: () async => await _blackListController.onRefresh(), + onRefresh: _blackListController.onRefresh, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), controller: _blackListController.scrollController, diff --git a/lib/pages/common/common_controller.dart b/lib/pages/common/common_controller.dart index 0f1695d6..1e138d4a 100644 --- a/lib/pages/common/common_controller.dart +++ b/lib/pages/common/common_controller.dart @@ -92,19 +92,19 @@ abstract class CommonController extends GetxController } @override - Future onRefresh() async { + Future onRefresh() { currentPage = 1; isEnd = false; - await queryData(); + return queryData(); } - Future onLoadMore() async { - await queryData(false); + Future onLoadMore() { + return queryData(false); } - Future onReload() async { + Future onReload() { loadingState.value = LoadingState.loading(); - await onRefresh(); + return onRefresh(); } @override diff --git a/lib/pages/common/common_publish_page.dart b/lib/pages/common/common_publish_page.dart index 4f03c2ea..8fd8597b 100644 --- a/lib/pages/common/common_publish_page.dart +++ b/lib/pages/common/common_publish_page.dart @@ -85,7 +85,7 @@ abstract class CommonPublishPageState void didChangeAppLifecycleState(AppLifecycleState state) { if (state == AppLifecycleState.resumed) { if (mounted && widget.autofocus && selectKeyboard.value) { - WidgetsBinding.instance.addPostFrameCallback((_) async { + WidgetsBinding.instance.addPostFrameCallback((_) { if (focusNode.hasFocus) { focusNode.unfocus(); _requestFocus(); @@ -102,7 +102,7 @@ abstract class CommonPublishPageState } } - Future updatePanelType(PanelType type) async { + void updatePanelType(PanelType type) { final isSwitchToKeyboard = PanelType.keyboard == type; final isSwitchToEmojiPanel = PanelType.emoji == type; bool isUpdated = false; diff --git a/lib/pages/dynamics/controller.dart b/lib/pages/dynamics/controller.dart index 05f2eb93..c8ee6a4e 100644 --- a/lib/pages/dynamics/controller.dart +++ b/lib/pages/dynamics/controller.dart @@ -69,7 +69,7 @@ class DynamicsController extends GetxController queryFollowUp(); } - Future onSelectType(value) async { + void onSelectType(value) { initialValue.value = value; } @@ -171,7 +171,7 @@ class DynamicsController extends GetxController isQuerying = false; } - Future onSelectUp(mid) async { + void onSelectUp(mid) { if (this.mid == mid) { tabController.index = (mid == -1 ? 0 : 4); if (mid == -1) { @@ -192,7 +192,7 @@ class DynamicsController extends GetxController } @override - Future animateToTop() async { + void animateToTop() { controller?.animateToTop(); scrollController.animToTop(); } diff --git a/lib/pages/dynamics/widgets/vote.dart b/lib/pages/dynamics/widgets/vote.dart index 02708a83..dad6cf2a 100644 --- a/lib/pages/dynamics/widgets/vote.dart +++ b/lib/pages/dynamics/widgets/vote.dart @@ -369,7 +369,7 @@ Future showVoteDialog(BuildContext context, int voteId, final voteInfo = await DynamicsHttp.voteInfo(voteId); if (context.mounted) { if (voteInfo.isSuccess) { - await showDialog( + showDialog( context: context, builder: (context) => AlertDialog( content: SizedBox( diff --git a/lib/pages/dynamics_detail/view.dart b/lib/pages/dynamics_detail/view.dart index 12a68c79..288bc3d8 100644 --- a/lib/pages/dynamics_detail/view.dart +++ b/lib/pages/dynamics_detail/view.dart @@ -323,11 +323,11 @@ class _DynamicDetailPageState extends State min: 1, max: 100, value: _ratio.first, - onChanged: (value) async { + onChanged: (value) { if (value >= 10 && value <= 90) { _ratio[0] = value; _ratio[1] = 100 - value; - await GStorage.setting.put( + GStorage.setting.put( SettingBoxKey.dynamicDetailRatio, _ratio, ); @@ -355,9 +355,7 @@ class _DynamicDetailPageState extends State bottom: false, child: context.orientation == Orientation.portrait ? refreshIndicator( - onRefresh: () async { - await _dynamicDetailController.onRefresh(); - }, + onRefresh: _dynamicDetailController.onRefresh, child: _buildBody(context.orientation, theme), ) : _buildBody(context.orientation, theme), @@ -425,9 +423,7 @@ class _DynamicDetailPageState extends State key: _key, backgroundColor: Colors.transparent, body: refreshIndicator( - onRefresh: () async { - await _dynamicDetailController.onRefresh(); - }, + onRefresh: _dynamicDetailController.onRefresh, child: CustomScrollView( controller: _dynamicDetailController.scrollController, diff --git a/lib/pages/dynamics_tab/controller.dart b/lib/pages/dynamics_tab/controller.dart index 8bb2e99b..813ff0af 100644 --- a/lib/pages/dynamics_tab/controller.dart +++ b/lib/pages/dynamics_tab/controller.dart @@ -3,6 +3,7 @@ import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/msg.dart'; import 'package:PiliPlus/models/dynamics/result.dart'; import 'package:PiliPlus/pages/common/common_list_controller.dart'; +import 'package:PiliPlus/pages/dynamics/controller.dart'; import 'package:PiliPlus/pages/main/controller.dart'; import 'package:PiliPlus/utils/extension.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -15,6 +16,7 @@ class DynamicsTabController String offset = ''; int mid = -1; late final MainController mainController = Get.find(); + DynamicsController dynamicsController = Get.find(); @override void onInit() { @@ -28,6 +30,7 @@ class DynamicsTabController mainController.setCount(); } offset = ''; + dynamicsController.queryFollowUp(); return super.onRefresh(); } diff --git a/lib/pages/dynamics_tab/view.dart b/lib/pages/dynamics_tab/view.dart index 2f7a579c..bc289a17 100644 --- a/lib/pages/dynamics_tab/view.dart +++ b/lib/pages/dynamics_tab/view.dart @@ -80,10 +80,7 @@ class _DynamicsTabPageState Widget build(BuildContext context) { super.build(context); return refreshIndicator( - onRefresh: () async { - dynamicsController.queryFollowUp(); - await controller.onRefresh(); - }, + onRefresh: controller.onRefresh, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), controller: controller.scrollController, diff --git a/lib/pages/fan/view.dart b/lib/pages/fan/view.dart index 91333113..cca7452b 100644 --- a/lib/pages/fan/view.dart +++ b/lib/pages/fan/view.dart @@ -55,7 +55,7 @@ class _FansPageState extends State { body: SafeArea( bottom: false, child: refreshIndicator( - onRefresh: () async => await _fansController.onRefresh(), + onRefresh: _fansController.onRefresh, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), controller: _fansController.scrollController, diff --git a/lib/pages/fav/article/view.dart b/lib/pages/fav/article/view.dart index c82e5db2..2c800829 100644 --- a/lib/pages/fav/article/view.dart +++ b/lib/pages/fav/article/view.dart @@ -29,9 +29,7 @@ class _FavArticlePageState extends State Widget build(BuildContext context) { super.build(context); return refreshIndicator( - onRefresh: () async { - await _favArticleController.onRefresh(); - }, + onRefresh: _favArticleController.onRefresh, child: CustomScrollView( slivers: [ SliverPadding( diff --git a/lib/pages/fav/note/child_view.dart b/lib/pages/fav/note/child_view.dart index 10b6c5d4..fa2fa7a4 100644 --- a/lib/pages/fav/note/child_view.dart +++ b/lib/pages/fav/note/child_view.dart @@ -34,9 +34,7 @@ class _FavNoteChildPageState extends State clipBehavior: Clip.none, children: [ refreshIndicator( - onRefresh: () async { - await _favNoteController.onRefresh(); - }, + onRefresh: _favNoteController.onRefresh, child: CustomScrollView( slivers: [ Obx(() => _buildBody(_favNoteController.loadingState.value)), diff --git a/lib/pages/fav/pgc/child_view.dart b/lib/pages/fav/pgc/child_view.dart index 51d3e150..b5c323d3 100644 --- a/lib/pages/fav/pgc/child_view.dart +++ b/lib/pages/fav/pgc/child_view.dart @@ -41,9 +41,7 @@ class _FavPgcChildPageState extends State clipBehavior: Clip.none, children: [ refreshIndicator( - onRefresh: () async { - await _favPgcController.onRefresh(); - }, + onRefresh: _favPgcController.onRefresh, child: CustomScrollView( slivers: [ Obx(() => _buildBody(_favPgcController.loadingState.value)), diff --git a/lib/pages/fav/video/view.dart b/lib/pages/fav/video/view.dart index ebc81787..3d263171 100644 --- a/lib/pages/fav/video/view.dart +++ b/lib/pages/fav/video/view.dart @@ -29,9 +29,7 @@ class _FavVideoPageState extends State Widget build(BuildContext context) { super.build(context); return refreshIndicator( - onRefresh: () async { - await _favController.onRefresh(); - }, + onRefresh: _favController.onRefresh, child: CustomScrollView( controller: _favController.scrollController, physics: const AlwaysScrollableScrollPhysics(), diff --git a/lib/pages/fav_create/view.dart b/lib/pages/fav_create/view.dart index c74b6b3e..f0bfa3be 100644 --- a/lib/pages/fav_create/view.dart +++ b/lib/pages/fav_create/view.dart @@ -175,8 +175,7 @@ class _CreateFavPageState extends State { tileColor: theme.colorScheme.onInverseSurface, onTap: () { EasyThrottle.throttle( - 'imagePicker', const Duration(milliseconds: 500), - () async { + 'imagePicker', const Duration(milliseconds: 500), () { if (_cover?.isNotEmpty == true) { showDialog( context: context, diff --git a/lib/pages/fav_detail/view.dart b/lib/pages/fav_detail/view.dart index eaa6f3fc..41325753 100644 --- a/lib/pages/fav_detail/view.dart +++ b/lib/pages/fav_detail/view.dart @@ -76,9 +76,7 @@ class _FavDetailPageState extends State { top: false, bottom: false, child: refreshIndicator( - onRefresh: () async { - await _favDetailController.onRefresh(); - }, + onRefresh: _favDetailController.onRefresh, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), controller: _favDetailController.scrollController, diff --git a/lib/pages/fav_panel/view.dart b/lib/pages/fav_panel/view.dart index 490a4562..204845bd 100644 --- a/lib/pages/fav_panel/view.dart +++ b/lib/pages/fav_panel/view.dart @@ -181,9 +181,9 @@ class _FavPanelState extends State { ), const SizedBox(width: 25), FilledButton.tonal( - onPressed: () async { + onPressed: () { feedBack(); - await widget.ctr.actionFavVideo(); + widget.ctr.actionFavVideo(); }, style: FilledButton.styleFrom( padding: const EdgeInsets.symmetric( diff --git a/lib/pages/follow/child_view.dart b/lib/pages/follow/child_view.dart index d75cd133..b473e9e7 100644 --- a/lib/pages/follow/child_view.dart +++ b/lib/pages/follow/child_view.dart @@ -62,9 +62,7 @@ class _FollowChildPageState extends State } Widget get _child => refreshIndicator( - onRefresh: () async { - await _followController.onRefresh(); - }, + onRefresh: _followController.onRefresh, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), slivers: [ diff --git a/lib/pages/history/base_controller.dart b/lib/pages/history/base_controller.dart index 49bb6e19..3e6eaffb 100644 --- a/lib/pages/history/base_controller.dart +++ b/lib/pages/history/base_controller.dart @@ -11,8 +11,8 @@ class HistoryBaseController extends GetxController { RxInt checkedCount = 0.obs; // 清空观看历史 - Future onClearHistory(BuildContext context, VoidCallback onSuccess) async { - await showDialog( + void onClearHistory(BuildContext context, VoidCallback onSuccess) { + showDialog( context: context, builder: (context) { return AlertDialog( @@ -40,8 +40,8 @@ class HistoryBaseController extends GetxController { } // 暂停观看历史 - Future onPauseHistory(BuildContext context) async { - await showDialog( + void onPauseHistory(BuildContext context) { + showDialog( context: context, builder: (context) { return AlertDialog( diff --git a/lib/pages/history/controller.dart b/lib/pages/history/controller.dart index 625aab1a..d7440ae5 100644 --- a/lib/pages/history/controller.dart +++ b/lib/pages/history/controller.dart @@ -102,7 +102,7 @@ class HistoryController extends MultiSelectController } // 删除某条历史记录 - Future delHistory(HisListItem item) async { + void delHistory(HisListItem item) { _onDelete([item]); } @@ -166,7 +166,7 @@ class HistoryController extends MultiSelectController ), ), TextButton( - onPressed: () async { + onPressed: () { Get.back(); if (loadingState.value is Success) { _onDelete(((loadingState.value as Success).response diff --git a/lib/pages/history/view.dart b/lib/pages/history/view.dart index 703ee398..4d0a2b53 100644 --- a/lib/pages/history/view.dart +++ b/lib/pages/history/view.dart @@ -238,9 +238,7 @@ class _HistoryPageState extends State } Widget get _buildPage => refreshIndicator( - onRefresh: () async { - await _historyController.onRefresh(); - }, + onRefresh: _historyController.onRefresh, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), controller: _historyController.scrollController, diff --git a/lib/pages/home/controller.dart b/lib/pages/home/controller.dart index f0268410..e7887ae1 100644 --- a/lib/pages/home/controller.dart +++ b/lib/pages/home/controller.dart @@ -72,7 +72,7 @@ class HomeController extends GetxController return controller.onRefresh().catchError((e) => debugPrint(e.toString())); } - Future setTabConfig() async { + void setTabConfig() { final defaultTabs = [...homeTabsConfig]; final tabbarSort = GStorage.tabbarSort; defaultTabs diff --git a/lib/pages/hot/view.dart b/lib/pages/hot/view.dart index 7c3a08b6..57f9d688 100644 --- a/lib/pages/hot/view.dart +++ b/lib/pages/hot/view.dart @@ -58,9 +58,7 @@ class _HotPageState extends CommonPageState Widget build(BuildContext context) { super.build(context); return refreshIndicator( - onRefresh: () async { - await controller.onRefresh(); - }, + onRefresh: controller.onRefresh, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), controller: controller.scrollController, diff --git a/lib/pages/later/child_view.dart b/lib/pages/later/child_view.dart index 4f544c6f..ca0292b8 100644 --- a/lib/pages/later/child_view.dart +++ b/lib/pages/later/child_view.dart @@ -38,9 +38,7 @@ class _LaterViewChildPageState extends State Widget build(BuildContext context) { super.build(context); return refreshIndicator( - onRefresh: () async { - await _laterController.onRefresh(); - }, + onRefresh: _laterController.onRefresh, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), controller: _laterController.scrollController, diff --git a/lib/pages/later/controller.dart b/lib/pages/later/controller.dart index 3a064d46..1f15e6cb 100644 --- a/lib/pages/later/controller.dart +++ b/lib/pages/later/controller.dart @@ -84,8 +84,8 @@ class LaterController extends MultiSelectController { } // single - Future toViewDel(BuildContext context, int index, int? aid) async { - await showDialog( + void toViewDel(BuildContext context, int index, int? aid) { + showDialog( context: context, builder: (context) { return AlertDialog( @@ -165,7 +165,7 @@ class LaterController extends MultiSelectController { ), ), TextButton( - onPressed: () async { + onPressed: () { Get.back(); _onDelete(((loadingState.value as Success).response as List) diff --git a/lib/pages/live/controller.dart b/lib/pages/live/controller.dart index 1d0e3e5a..1cdc004b 100644 --- a/lib/pages/live/controller.dart +++ b/lib/pages/live/controller.dart @@ -68,13 +68,13 @@ class LiveController extends CommonListController { } @override - Future onRefresh() async { + Future onRefresh() { currentPage = 1; isEnd = false; if (areaIndex.value != 0) { queryTop(); } - await queryData(); + return queryData(); } Future queryTop() async { diff --git a/lib/pages/live/view.dart b/lib/pages/live/view.dart index dd7ecfe8..95139635 100644 --- a/lib/pages/live/view.dart +++ b/lib/pages/live/view.dart @@ -46,9 +46,7 @@ class _LivePageState extends CommonPageState borderRadius: StyleString.mdRadius, ), child: refreshIndicator( - onRefresh: () async { - await controller.onRefresh(); - }, + onRefresh: controller.onRefresh, child: CustomScrollView( controller: controller.scrollController, physics: const AlwaysScrollableScrollPhysics(), diff --git a/lib/pages/live_follow/view.dart b/lib/pages/live_follow/view.dart index 403c2f46..8f31bfa6 100644 --- a/lib/pages/live_follow/view.dart +++ b/lib/pages/live_follow/view.dart @@ -34,9 +34,7 @@ class _LiveFollowPageState extends State { top: false, bottom: false, child: refreshIndicator( - onRefresh: () async { - await _controller.onRefresh(); - }, + onRefresh: _controller.onRefresh, child: CustomScrollView( slivers: [ SliverPadding( diff --git a/lib/pages/live_room/controller.dart b/lib/pages/live_room/controller.dart index 8941c0fa..4c650c86 100644 --- a/lib/pages/live_room/controller.dart +++ b/lib/pages/live_room/controller.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'package:PiliPlus/http/constants.dart'; @@ -235,14 +236,14 @@ class LiveRoomController extends GetxController { } // 修改画质 - Future changeQn(int qn) async { + FutureOr changeQn(int qn) { if (currentQn == qn) { - return; + return null; } currentQn = qn; currentQnDesc.value = LiveQuality.values .firstWhere((element) => element.code == currentQn) .description; - await queryLiveInfo(); + return queryLiveInfo(); } } diff --git a/lib/pages/login/controller.dart b/lib/pages/login/controller.dart index aa173af2..bbe20ac2 100644 --- a/lib/pages/login/controller.dart +++ b/lib/pages/login/controller.dart @@ -110,7 +110,7 @@ class LoginPageController extends GetxController } // 申请极验验证码 - Future getCaptcha(geeGt, geeChallenge, onSuccess) async { + void getCaptcha(geeGt, geeChallenge, onSuccess) { var registerData = Gt3RegisterData( challenge: geeChallenge, gt: geeGt, @@ -119,11 +119,11 @@ class LoginPageController extends GetxController captcha ..addEventHandler( - onShow: (Map message) async {}, - onClose: (Map message) async { + onShow: (Map message) {}, + onClose: (Map message) { SmartDialog.showToast('关闭验证'); }, - onResult: (Map message) async { + onResult: (Map message) { debugPrint("Captcha result: $message"); String code = message["code"]; if (code == "1") { @@ -142,7 +142,7 @@ class LoginPageController extends GetxController debugPrint("Captcha result code : $code"); } }, - onError: (Map message) async { + onError: (Map message) { SmartDialog.showToast("Captcha onError: $message"); String code = message["code"]; // 处理验证中返回的错误 Handling errors returned in verification diff --git a/lib/pages/login/view.dart b/lib/pages/login/view.dart index 975825c3..99d3d5dd 100644 --- a/lib/pages/login/view.dart +++ b/lib/pages/login/view.dart @@ -276,7 +276,7 @@ class _LoginPageState extends State { 'https://passport.bilibili.com/pc/passport/findPassword', ), dense: false, - onTap: () async { + onTap: () { Get ..back() ..toNamed('/webview', parameters: { diff --git a/lib/pages/main/controller.dart b/lib/pages/main/controller.dart index 37be0615..b3beb66f 100644 --- a/lib/pages/main/controller.dart +++ b/lib/pages/main/controller.dart @@ -202,7 +202,7 @@ class MainController extends GetxController { } } - Future setNavBarConfig() async { + void setNavBarConfig() { List defaultNavTabs = [...defaultNavigationBars]; List navBarSort = GStorage.setting.get(SettingBoxKey.navBarSort, defaultValue: [0, 1, 2]); diff --git a/lib/pages/main/view.dart b/lib/pages/main/view.dart index 2c3d73ab..7315a61a 100644 --- a/lib/pages/main/view.dart +++ b/lib/pages/main/view.dart @@ -124,7 +124,7 @@ class _MainAppState extends State } } - Future setIndex(int value) async { + void setIndex(int value) { feedBack(); if (value != _mainController.selectedIndex.value) { @@ -181,7 +181,7 @@ class _MainAppState extends State final bool isPortrait = context.orientation == Orientation.portrait; return PopScope( canPop: false, - onPopInvokedWithResult: (bool didPop, Object? result) async { + onPopInvokedWithResult: (bool didPop, Object? result) { if (_mainController.selectedIndex.value != 0) { setIndex(0); _mainController.bottomBarStream?.add(true); diff --git a/lib/pages/member/controller.dart b/lib/pages/member/controller.dart index 90c8224e..b3fd8a27 100644 --- a/lib/pages/member/controller.dart +++ b/lib/pages/member/controller.dart @@ -151,12 +151,12 @@ class MemberController extends CommonDataController fromViewAid: fromViewAid, ); - Future blockUser(BuildContext context) async { + void blockUser(BuildContext context) { if (ownerMid == 0) { SmartDialog.showToast('账号未登录'); return; } - await showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( @@ -171,7 +171,7 @@ class MemberController extends CommonDataController ), ), TextButton( - onPressed: () async { + onPressed: () { Get.back(); _onBlock(); }, @@ -198,7 +198,7 @@ class MemberController extends CommonDataController } } - Future onFollow(BuildContext context) async { + void onFollow(BuildContext context) { if (mid == ownerMid) { Get.toNamed('/editProfile'); } else if (relation.value == 128) { diff --git a/lib/pages/member_article/view.dart b/lib/pages/member_article/view.dart index ff1ad9cd..bf9f378b 100644 --- a/lib/pages/member_article/view.dart +++ b/lib/pages/member_article/view.dart @@ -43,9 +43,7 @@ class _MemberArticleState extends State Loading() => loadingWidget, Success() => loadingState.response?.isNotEmpty == true ? refreshIndicator( - onRefresh: () async { - await _controller.onRefresh(); - }, + onRefresh: _controller.onRefresh, child: CustomScrollView( slivers: [ SliverPadding( diff --git a/lib/pages/member_dynamics/view.dart b/lib/pages/member_dynamics/view.dart index 516abfc6..75676650 100644 --- a/lib/pages/member_dynamics/view.dart +++ b/lib/pages/member_dynamics/view.dart @@ -54,9 +54,7 @@ class _MemberDynamicsPageState extends State } Widget get _buildBody => refreshIndicator( - onRefresh: () async { - await _memberDynamicController.onRefresh(); - }, + onRefresh: _memberDynamicController.onRefresh, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), slivers: [ diff --git a/lib/pages/member_favorite/view.dart b/lib/pages/member_favorite/view.dart index 50ef4a37..a32c98d1 100644 --- a/lib/pages/member_favorite/view.dart +++ b/lib/pages/member_favorite/view.dart @@ -44,9 +44,7 @@ class _MemberFavoriteState extends State Loading() => loadingWidget, Success() => (loadingState.response as List?)?.isNotEmpty == true ? refreshIndicator( - onRefresh: () async { - await _controller.onRefresh(); - }, + onRefresh: _controller.onRefresh, child: CustomScrollView( slivers: [ SliverToBoxAdapter( diff --git a/lib/pages/member_pgc/view.dart b/lib/pages/member_pgc/view.dart index d5cb610f..b32aabfd 100644 --- a/lib/pages/member_pgc/view.dart +++ b/lib/pages/member_pgc/view.dart @@ -47,9 +47,7 @@ class _MemberBangumiState extends State Loading() => loadingWidget, Success() => loadingState.response?.isNotEmpty == true ? refreshIndicator( - onRefresh: () async { - await _controller.onRefresh(); - }, + onRefresh: _controller.onRefresh, child: CustomScrollView( slivers: [ SliverPadding( diff --git a/lib/pages/member_profile/view.dart b/lib/pages/member_profile/view.dart index d77264f1..8dcfe20b 100644 --- a/lib/pages/member_profile/view.dart +++ b/lib/pages/member_profile/view.dart @@ -107,8 +107,7 @@ class _EditProfilePageState extends State { ), onTap: () { EasyThrottle.throttle( - 'imagePicker', const Duration(milliseconds: 500), - () async { + 'imagePicker', const Duration(milliseconds: 500), () { _pickImg(theme); }); }, diff --git a/lib/pages/member_video/view.dart b/lib/pages/member_video/view.dart index 0ae596d1..c8d33436 100644 --- a/lib/pages/member_video/view.dart +++ b/lib/pages/member_video/view.dart @@ -68,9 +68,7 @@ class _MemberVideoState extends State clipBehavior: Clip.none, children: [ refreshIndicator( - onRefresh: () async { - await _controller.onRefresh(); - }, + onRefresh: _controller.onRefresh, child: CustomScrollView( physics: PositionRetainedScrollPhysics( shouldRetain: _controller.isLocating == true, diff --git a/lib/pages/mine/controller.dart b/lib/pages/mine/controller.dart index e4e9f98f..b87195c7 100644 --- a/lib/pages/mine/controller.dart +++ b/lib/pages/mine/controller.dart @@ -39,7 +39,7 @@ class MineController extends GetxController { } } - Future onLogin([bool longPress = false]) async { + void onLogin([bool longPress = false]) { if (!isLogin.value || longPress) { Get.toNamed('/loginPage', preventDuplicates: false); } else { diff --git a/lib/pages/msg_feed_top/at_me/view.dart b/lib/pages/msg_feed_top/at_me/view.dart index aa942ce1..2aee2834 100644 --- a/lib/pages/msg_feed_top/at_me/view.dart +++ b/lib/pages/msg_feed_top/at_me/view.dart @@ -29,9 +29,7 @@ class _AtMePageState extends State { title: const Text('@我的'), ), body: refreshIndicator( - onRefresh: () async { - await _atMeController.onRefresh(); - }, + onRefresh: _atMeController.onRefresh, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), slivers: [ diff --git a/lib/pages/msg_feed_top/like_me/view.dart b/lib/pages/msg_feed_top/like_me/view.dart index 4fd12963..a9e713af 100644 --- a/lib/pages/msg_feed_top/like_me/view.dart +++ b/lib/pages/msg_feed_top/like_me/view.dart @@ -29,9 +29,7 @@ class _LikeMePageState extends State { title: const Text('收到的赞'), ), body: refreshIndicator( - onRefresh: () async { - await _likeMeController.onRefresh(); - }, + onRefresh: _likeMeController.onRefresh, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), slivers: [ diff --git a/lib/pages/msg_feed_top/reply_me/view.dart b/lib/pages/msg_feed_top/reply_me/view.dart index a5e39b9f..e92aacbe 100644 --- a/lib/pages/msg_feed_top/reply_me/view.dart +++ b/lib/pages/msg_feed_top/reply_me/view.dart @@ -27,9 +27,7 @@ class _ReplyMePageState extends State { return Scaffold( appBar: AppBar(title: const Text('回复我的')), body: refreshIndicator( - onRefresh: () async { - await _replyMeController.onRefresh(); - }, + onRefresh: _replyMeController.onRefresh, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), slivers: [ diff --git a/lib/pages/msg_feed_top/sys_msg/controller.dart b/lib/pages/msg_feed_top/sys_msg/controller.dart index b38622d8..b19e60bf 100644 --- a/lib/pages/msg_feed_top/sys_msg/controller.dart +++ b/lib/pages/msg_feed_top/sys_msg/controller.dart @@ -27,7 +27,7 @@ class SysMsgController } } - Future msgSysUpdateCursor(int? cursor) async { + void msgSysUpdateCursor(int? cursor) { if (cursor != null) { MsgHttp.msgSysUpdateCursor(cursor); } diff --git a/lib/pages/msg_feed_top/sys_msg/view.dart b/lib/pages/msg_feed_top/sys_msg/view.dart index 5fd05193..9ad19778 100644 --- a/lib/pages/msg_feed_top/sys_msg/view.dart +++ b/lib/pages/msg_feed_top/sys_msg/view.dart @@ -34,9 +34,7 @@ class _SysMsgPageState extends State { title: const Text('系统通知'), ), body: refreshIndicator( - onRefresh: () async { - await _sysMsgController.onRefresh(); - }, + onRefresh: _sysMsgController.onRefresh, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), slivers: [ diff --git a/lib/pages/rank/zone/view.dart b/lib/pages/rank/zone/view.dart index aa2563b4..1af63511 100644 --- a/lib/pages/rank/zone/view.dart +++ b/lib/pages/rank/zone/view.dart @@ -37,9 +37,7 @@ class _ZonePageState extends CommonPageState Widget build(BuildContext context) { super.build(context); return refreshIndicator( - onRefresh: () async { - await controller.onRefresh(); - }, + onRefresh: controller.onRefresh, child: CustomScrollView( controller: controller.scrollController, slivers: [ diff --git a/lib/pages/rcmd/controller.dart b/lib/pages/rcmd/controller.dart index 31f80ba6..52021437 100644 --- a/lib/pages/rcmd/controller.dart +++ b/lib/pages/rcmd/controller.dart @@ -44,9 +44,9 @@ class RcmdController extends CommonListController { } @override - Future onRefresh() async { + Future onRefresh() { currentPage = 0; isEnd = false; - await queryData(); + return queryData(); } } diff --git a/lib/pages/rcmd/view.dart b/lib/pages/rcmd/view.dart index 2a0bfd0b..65aa7de5 100644 --- a/lib/pages/rcmd/view.dart +++ b/lib/pages/rcmd/view.dart @@ -33,9 +33,7 @@ class _RcmdPageState extends CommonPageState margin: const EdgeInsets.symmetric(horizontal: StyleString.safeSpace), decoration: const BoxDecoration(borderRadius: StyleString.mdRadius), child: refreshIndicator( - onRefresh: () async { - await controller.onRefresh(); - }, + onRefresh: controller.onRefresh, child: CustomScrollView( controller: controller.scrollController, physics: const AlwaysScrollableScrollPhysics(), diff --git a/lib/pages/search_panel/all/controller.dart b/lib/pages/search_panel/all/controller.dart index 52d5f1bc..114829fa 100644 --- a/lib/pages/search_panel/all/controller.dart +++ b/lib/pages/search_panel/all/controller.dart @@ -51,7 +51,7 @@ class SearchAllController pubEnd: pubEnd, ); - Future onPushDetail(resultList) async { + void onPushDetail(resultList) { try { int? aid = int.tryParse(keyword); if (aid != null && resultList.first.aid == aid) { diff --git a/lib/pages/search_panel/live/widgets/item.dart b/lib/pages/search_panel/live/widgets/item.dart index 1e5c5ea6..c81672ae 100644 --- a/lib/pages/search_panel/live/widgets/item.dart +++ b/lib/pages/search_panel/live/widgets/item.dart @@ -18,7 +18,7 @@ class LiveItem extends StatelessWidget { clipBehavior: Clip.hardEdge, margin: EdgeInsets.zero, child: InkWell( - onTap: () async { + onTap: () { Get.toNamed('/liveRoom?roomid=${liveItem.roomid}'); }, onLongPress: () => imageSaveDialog( diff --git a/lib/pages/search_panel/video/controller.dart b/lib/pages/search_panel/video/controller.dart index 483cee16..609feb98 100644 --- a/lib/pages/search_panel/video/controller.dart +++ b/lib/pages/search_panel/video/controller.dart @@ -62,7 +62,7 @@ class SearchVideoController return false; } - Future onPushDetail(resultList) async { + void onPushDetail(resultList) { try { int? aid = int.tryParse(keyword); if (aid != null && resultList.first.aid == aid) { diff --git a/lib/pages/search_panel/view.dart b/lib/pages/search_panel/view.dart index 4986ceed..be8c18ca 100644 --- a/lib/pages/search_panel/view.dart +++ b/lib/pages/search_panel/view.dart @@ -40,9 +40,7 @@ abstract class CommonSearchPanelState< super.build(context); final theme = Theme.of(context); return refreshIndicator( - onRefresh: () async { - await controller.onRefresh(); - }, + onRefresh: controller.onRefresh, child: CustomScrollView( controller: controller.scrollController, physics: const AlwaysScrollableScrollPhysics(), diff --git a/lib/pages/search_trending/view.dart b/lib/pages/search_trending/view.dart index 9784ba85..2c99e885 100644 --- a/lib/pages/search_trending/view.dart +++ b/lib/pages/search_trending/view.dart @@ -109,9 +109,7 @@ class _SearchTrendingPageState extends State { removeLeft: removePadding, removeRight: removePadding, child: refreshIndicator( - onRefresh: () async { - await _controller.onRefresh(); - }, + onRefresh: _controller.onRefresh, child: CustomScrollView( controller: _controller.scrollController, slivers: [ diff --git a/lib/pages/setting/pages/color_select.dart b/lib/pages/setting/pages/color_select.dart index b0a5eac4..687a19b5 100644 --- a/lib/pages/setting/pages/color_select.dart +++ b/lib/pages/setting/pages/color_select.dart @@ -97,9 +97,9 @@ class _ColorSelectPageState extends State { PopupMenuButton( enabled: ctr.type.value != 0, initialValue: _dynamicSchemeVariant, - onSelected: (item) async { + onSelected: (item) { _dynamicSchemeVariant = item; - await GStorage.setting + GStorage.setting .put(SettingBoxKey.schemeVariant, item.index); Get.forceAppUpdate(); }, @@ -151,7 +151,7 @@ class _ColorSelectPageState extends State { value: 0, title: const Text('动态取色'), groupValue: ctr.type.value, - onChanged: (dynamic val) async { + onChanged: (dynamic val) { ctr.type.value = 0; ctr.setting.put(SettingBoxKey.dynamicColor, true); Get.forceAppUpdate(); @@ -163,7 +163,7 @@ class _ColorSelectPageState extends State { value: 1, title: const Text('指定颜色'), groupValue: ctr.type.value, - onChanged: (dynamic val) async { + onChanged: (dynamic val) { ctr.type.value = 1; ctr.setting.put(SettingBoxKey.dynamicColor, false); Get.forceAppUpdate(); diff --git a/lib/pages/setting/pages/display_mode.dart b/lib/pages/setting/pages/display_mode.dart index 5bbcc5ce..35fdb869 100644 --- a/lib/pages/setting/pages/display_mode.dart +++ b/lib/pages/setting/pages/display_mode.dart @@ -59,13 +59,13 @@ class _SetDisplayModeState extends State { } on PlatformException catch (e) { debugPrint(e.toString()); } - var res = await getDisplayModeType(modes); + var res = getDisplayModeType(modes); preferred = modes.toList().firstWhere((el) => el == res); FlutterDisplayMode.setPreferredMode(preferred!); } - Future getDisplayModeType(modes) async { + DisplayMode getDisplayModeType(modes) { var value = setting.get(SettingBoxKey.displayMode); DisplayMode f = DisplayMode.auto; if (value != null) { diff --git a/lib/pages/setting/pages/logs.dart b/lib/pages/setting/pages/logs.dart index 926f9251..9b1fd22a 100644 --- a/lib/pages/setting/pages/logs.dart +++ b/lib/pages/setting/pages/logs.dart @@ -38,11 +38,11 @@ class _LogsPageState extends State { Future getPath() async { logsPath = await getLogsPath(); fileContent = await logsPath.readAsString(); - logsContent = await parseLogs(fileContent); + logsContent = parseLogs(fileContent); setState(() {}); } - Future>> parseLogs(String fileContent) async { + List> parseLogs(String fileContent) { const String splitToken = '======================================================================'; List contentList = fileContent.split(splitToken).map((item) { @@ -83,8 +83,8 @@ class _LogsPageState extends State { return result.reversed.toList(); } - Future copyLogs() async { - await Utils.copyText('```\n$fileContent\n```', needToast: false); + void copyLogs() { + Utils.copyText('```\n$fileContent\n```', needToast: false); if (mounted) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('复制成功')), @@ -177,8 +177,8 @@ class _LogsPageState extends State { tapTargetSize: MaterialTapTargetSize.shrinkWrap, visualDensity: VisualDensity.compact, ), - onPressed: () async { - await Utils.copyText('```\n${log['body']}\n```', + onPressed: () { + Utils.copyText('```\n${log['body']}\n```', needToast: false); if (context.mounted) { ScaffoldMessenger.of(context).showSnackBar( diff --git a/lib/pages/setting/pages/play_speed_set.dart b/lib/pages/setting/pages/play_speed_set.dart index 9462812f..2213edad 100644 --- a/lib/pages/setting/pages/play_speed_set.dart +++ b/lib/pages/setting/pages/play_speed_set.dart @@ -108,7 +108,7 @@ class _PlaySpeedPageState extends State { child: const Text('取消'), ), TextButton( - onPressed: () async { + onPressed: () { if (customSpeed == null) { SmartDialog.showToast('输入倍数不合法'); } else if (speedList.contains(customSpeed)) { @@ -118,7 +118,7 @@ class _PlaySpeedPageState extends State { speedList ..add(customSpeed!) ..sort(); - await video.put(VideoBoxKey.speedsList, speedList); + video.put(VideoBoxKey.speedsList, speedList); setState(() {}); } }, @@ -168,7 +168,7 @@ class _PlaySpeedPageState extends State { } // - Future menuAction(index, id) async { + void menuAction(index, id) { double speed = speedList[index]; // 设置 if (id == 1) { @@ -189,7 +189,7 @@ class _PlaySpeedPageState extends State { return; } speedList.removeAt(index); - await video.put(VideoBoxKey.speedsList, speedList); + video.put(VideoBoxKey.speedsList, speedList); } setState(() {}); } diff --git a/lib/pages/setting/widgets/model.dart b/lib/pages/setting/widgets/model.dart index 605079e0..f7e8101f 100644 --- a/lib/pages/setting/widgets/model.dart +++ b/lib/pages/setting/widgets/model.dart @@ -2651,7 +2651,7 @@ SettingsModel _getVideoFilterSelectModel({ ); if (result != null) { if (result == -1 && context.mounted) { - await showDialog( + showDialog( context: context, builder: (context) { String valueStr = ''; diff --git a/lib/pages/subscription/controller.dart b/lib/pages/subscription/controller.dart index 6fe57396..62f49a03 100644 --- a/lib/pages/subscription/controller.dart +++ b/lib/pages/subscription/controller.dart @@ -28,7 +28,7 @@ class SubController } // 取消订阅 - Future cancelSub(SubFolderItemData subFolderItem) async { + void cancelSub(SubFolderItemData subFolderItem) { showDialog( context: Get.context!, builder: (context) => AlertDialog( diff --git a/lib/pages/subscription/view.dart b/lib/pages/subscription/view.dart index 6de3f3d6..2387440c 100644 --- a/lib/pages/subscription/view.dart +++ b/lib/pages/subscription/view.dart @@ -27,9 +27,7 @@ class _SubPageState extends State { top: false, bottom: false, child: refreshIndicator( - onRefresh: () async { - await _subController.onRefresh(); - }, + onRefresh: _subController.onRefresh, child: CustomScrollView( slivers: [ Obx(() => _buildBody(_subController.loadingState.value)), diff --git a/lib/pages/video/controller.dart b/lib/pages/video/controller.dart index 5ab9b07c..1304303d 100644 --- a/lib/pages/video/controller.dart +++ b/lib/pages/video/controller.dart @@ -371,7 +371,7 @@ class VideoDetailController extends GetxController }, loadPrevious: Get.arguments['isContinuePlaying'] == true ? () { - getMediaList(isLoadPrevious: true); + return getMediaList(isLoadPrevious: true); } : null, onDelete: sourceType == 'watchLater' || @@ -441,7 +441,7 @@ class VideoDetailController extends GetxController late final listKey = GlobalKey(); late final List listData = []; - Future _vote(String uuid, int type) async { + void _vote(String uuid, int type) { Request().post( '$blockServer/api/voteOnSponsorTime', queryParameters: { @@ -619,7 +619,7 @@ class VideoDetailController extends GetxController tooltip: item.skipType == SkipType.showOnly ? '跳至此片段' : '跳过此片段', - onPressed: () async { + onPressed: () { Get.back(); onSkip( item, @@ -943,7 +943,7 @@ class VideoDetailController extends GetxController progress: plPlayerController.position.value.inMilliseconds, initialValue: savedDanmaku, onSave: (danmaku) => savedDanmaku = danmaku, - callback: (danmakuModel) async { + callback: (danmakuModel) { savedDanmaku = null; plPlayerController.danmakuController?.addDanmaku(danmakuModel); }, @@ -1614,7 +1614,7 @@ class VideoDetailController extends GetxController } } - Future showNoteList(BuildContext context) async { + void showNoteList(BuildContext context) { String? title; try { title = diff --git a/lib/pages/video/introduction/pgc/controller.dart b/lib/pages/video/introduction/pgc/controller.dart index 89b13e80..4a73a9f2 100644 --- a/lib/pages/video/introduction/pgc/controller.dart +++ b/lib/pages/video/introduction/pgc/controller.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'package:PiliPlus/http/constants.dart'; @@ -253,7 +254,7 @@ class BangumiIntroController } // 分享视频 - Future actionShareVideo(context) async { + void actionShareVideo(context) { showDialog( context: context, builder: (_) { @@ -395,7 +396,7 @@ class BangumiIntroController } // 修改分P或番剧分集 - Future changeSeasonOrbangu(epId, bvid, cid, aid, cover) async { + void changeSeasonOrbangu(epId, bvid, cid, aid, cover) { // 重新获取视频资源 this.epId = epId; this.bvid = bvid; @@ -570,7 +571,7 @@ class BangumiIntroController if (hasLike.value && hasCoin && hasFav.value) { // 已点赞、投币、收藏 SmartDialog.showToast('已三连'); - return false; + return; } var result = await VideoHttp.triple(epId: epId, seasonId: seasonId); if (result['status']) { diff --git a/lib/pages/video/introduction/ugc/controller.dart b/lib/pages/video/introduction/ugc/controller.dart index 3e069dec..c7425e56 100644 --- a/lib/pages/video/introduction/ugc/controller.dart +++ b/lib/pages/video/introduction/ugc/controller.dart @@ -245,7 +245,7 @@ class VideoIntroController extends GetxController { if (hasLike.value && hasCoin && hasFav.value) { // 已点赞、投币、收藏 SmartDialog.showToast('已三连'); - return false; + return; } var result = await VideoHttp.oneThree(bvid: bvid); if (result['status']) { @@ -316,7 +316,7 @@ class VideoIntroController extends GetxController { SmartDialog.showToast(res['msg']); } - Future coinVideo(int coin, [bool selectLike = false]) async { + Future coinVideo(int coin, [bool selectLike = false]) async { if (videoDetail.value.stat?.coin == null) { // not init return; @@ -432,7 +432,7 @@ class VideoIntroController extends GetxController { } // 分享视频 - Future actionShareVideo(context) async { + void actionShareVideo(context) { showDialog( context: context, builder: (_) { diff --git a/lib/pages/video/introduction/ugc/view.dart b/lib/pages/video/introduction/ugc/view.dart index ea1b2d3a..04f9dcea 100644 --- a/lib/pages/video/introduction/ugc/view.dart +++ b/lib/pages/video/introduction/ugc/view.dart @@ -201,7 +201,7 @@ class _VideoInfoState extends State { style: const TextStyle(fontSize: 16), ); - Future handleState(Future Function() action) async { + Future handleState(FutureOr Function() action) async { if (isProcessing.not) { isProcessing = true; await action(); diff --git a/lib/pages/video/medialist/view.dart b/lib/pages/video/medialist/view.dart index baacea47..65ca84d6 100644 --- a/lib/pages/video/medialist/view.dart +++ b/lib/pages/video/medialist/view.dart @@ -11,7 +11,7 @@ import 'package:PiliPlus/models/common/badge_type.dart'; import 'package:PiliPlus/models/video/later.dart'; import 'package:PiliPlus/pages/common/common_collapse_slide_page.dart'; import 'package:PiliPlus/utils/utils.dart'; -import 'package:flutter/material.dart'; +import 'package:flutter/material.dart' hide RefreshCallback; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; @@ -40,7 +40,7 @@ class MediaListPanel extends CommonCollapseSlidePage { final int? count; final bool desc; final VoidCallback onReverse; - final Function? loadPrevious; + final RefreshCallback? loadPrevious; final ValueChanged? onDelete; @override @@ -126,9 +126,7 @@ class _MediaListPanelState Widget buildList(ThemeData theme) { return widget.loadPrevious != null ? refreshIndicator( - onRefresh: () async { - await widget.loadPrevious!(); - }, + onRefresh: widget.loadPrevious!, child: _buildList(theme), ) : _buildList(theme); diff --git a/lib/pages/video/member/controller.dart b/lib/pages/video/member/controller.dart index ddcd3811..1142e6ee 100644 --- a/lib/pages/video/member/controller.dart +++ b/lib/pages/video/member/controller.dart @@ -97,11 +97,11 @@ class HorizontalMemberPageController extends CommonDataController { ); @override - Future onRefresh() async { + Future onRefresh() { currentPage = 0; hasPrev = true; hasNext = true; - await queryData(); + return queryData(); } void queryBySort() { diff --git a/lib/pages/video/note/view.dart b/lib/pages/video/note/view.dart index d0fc43af..d5c3e16b 100644 --- a/lib/pages/video/note/view.dart +++ b/lib/pages/video/note/view.dart @@ -149,9 +149,7 @@ class _NoteListPageState extends CommonSlidePageState { ), Success() => loadingState.response?.isNotEmpty == true ? refreshIndicator( - onRefresh: () async { - await _controller.onRefresh(); - }, + onRefresh: _controller.onRefresh, child: CustomScrollView( controller: _controller.scrollController, physics: const AlwaysScrollableScrollPhysics(), diff --git a/lib/pages/video/pay_coins/view.dart b/lib/pages/video/pay_coins/view.dart index 79655731..52b8709c 100644 --- a/lib/pages/video/pay_coins/view.dart +++ b/lib/pages/video/pay_coins/view.dart @@ -23,11 +23,11 @@ class PayCoinsPage extends StatefulWidget { @override State createState() => _PayCoinsPageState(); - static Future toPayCoinsPage({ + static void toPayCoinsPage({ required Function(int coin, bool coinWithLike) onPayCoin, int copyright = 1, bool hasCoin = false, - }) async { + }) { Navigator.of(Get.context!).push( GetDialogRoute( pageBuilder: (buildContext, animation, secondaryAnimation) { diff --git a/lib/pages/video/post_panel/view.dart b/lib/pages/video/post_panel/view.dart index 4d251d9b..6b1176b0 100644 --- a/lib/pages/video/post_panel/view.dart +++ b/lib/pages/video/post_panel/view.dart @@ -162,7 +162,7 @@ class _PostPanelState extends CommonCollapseSlidePageState { const Text('分类: '), PopupMenuButton( initialValue: list![index].category, - onSelected: (item) async { + onSelected: (item) { list![index].category = item; List constraintList = item.toActionType; @@ -237,7 +237,7 @@ class _PostPanelState extends CommonCollapseSlidePageState { const Text('行为类别: '), PopupMenuButton( initialValue: list![index].actionType, - onSelected: (item) async { + onSelected: (item) { list![index].actionType = item; if (item == ActionType.full) { updateSegment( diff --git a/lib/pages/video/reply/view.dart b/lib/pages/video/reply/view.dart index 9d6ab63b..38dba714 100644 --- a/lib/pages/video/reply/view.dart +++ b/lib/pages/video/reply/view.dart @@ -101,9 +101,7 @@ class _VideoReplyPanelState extends State super.build(context); final theme = Theme.of(context); return refreshIndicator( - onRefresh: () async { - await _videoReplyController.onRefresh(); - }, + onRefresh: _videoReplyController.onRefresh, child: Stack( clipBehavior: Clip.none, children: [ diff --git a/lib/pages/video/reply/widgets/reply_item_grpc.dart b/lib/pages/video/reply/widgets/reply_item_grpc.dart index 9f17f0d4..815163f4 100644 --- a/lib/pages/video/reply/widgets/reply_item_grpc.dart +++ b/lib/pages/video/reply/widgets/reply_item_grpc.dart @@ -760,7 +760,7 @@ class ReplyItemGrpc extends StatelessWidget { color: theme.colorScheme.primary, ), recognizer: TapGestureRecognizer() - ..onTap = () async { + ..onTap = () { late final String title = content.urls[matchStr]!.title; if (appUrlSchema == '') { if (RegExp(r'^(av|bv)', caseSensitive: false) diff --git a/lib/pages/video/reply/widgets/zan_grpc.dart b/lib/pages/video/reply/widgets/zan_grpc.dart index 601155d3..5fc99a61 100644 --- a/lib/pages/video/reply/widgets/zan_grpc.dart +++ b/lib/pages/video/reply/widgets/zan_grpc.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart' show ReplyInfo; import 'package:PiliPlus/http/reply.dart'; diff --git a/lib/pages/video/reply_reply/view.dart b/lib/pages/video/reply_reply/view.dart index f1a54d1f..1394e254 100644 --- a/lib/pages/video/reply_reply/view.dart +++ b/lib/pages/video/reply_reply/view.dart @@ -160,9 +160,7 @@ class _VideoReplyReplyPanelState Widget buildList(ThemeData theme) { return ClipRect( child: refreshIndicator( - onRefresh: () async { - await _videoReplyReplyController.onRefresh(); - }, + onRefresh: _videoReplyReplyController.onRefresh, child: Obx( () => Stack( clipBehavior: Clip.none, diff --git a/lib/pages/video/view.dart b/lib/pages/video/view.dart index 512500a7..cf4f6ad2 100644 --- a/lib/pages/video/view.dart +++ b/lib/pages/video/view.dart @@ -305,7 +305,7 @@ class _VideoDetailPageVState extends State } // 继续播放或重新播放 - Future continuePlay() async { + void continuePlay() { plPlayerController!.play(); } diff --git a/lib/pages/webdav/webdav.dart b/lib/pages/webdav/webdav.dart index 12706655..d781ea9c 100644 --- a/lib/pages/webdav/webdav.dart +++ b/lib/pages/webdav/webdav.dart @@ -63,7 +63,7 @@ class WebDav { } } try { - String data = await GStorage.exportAllSettings(); + String data = GStorage.exportAllSettings(); _fileName ??= _getFileName(); final path = '$_webdavDirectory/$_fileName'; try { diff --git a/lib/pages/webview/view.dart b/lib/pages/webview/view.dart index f1aa7c25..87229ea2 100644 --- a/lib/pages/webview/view.dart +++ b/lib/pages/webview/view.dart @@ -243,7 +243,7 @@ class _WebviewPageState extends State { child: const Text('取消'), ), TextButton( - onPressed: () async { + onPressed: () { Get.back(); PageUtils.launchURL(request.url.toString()); }, diff --git a/lib/pages/whisper/view.dart b/lib/pages/whisper/view.dart index f6e6db90..6a63b0fc 100644 --- a/lib/pages/whisper/view.dart +++ b/lib/pages/whisper/view.dart @@ -45,9 +45,7 @@ class _WhisperPageState extends State { ], ), body: refreshIndicator( - onRefresh: () async { - await _whisperController.onRefresh(); - }, + onRefresh: _whisperController.onRefresh, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), slivers: [ diff --git a/lib/pages/whisper_detail/controller.dart b/lib/pages/whisper_detail/controller.dart index 5ecd0598..6c179ed8 100644 --- a/lib/pages/whisper_detail/controller.dart +++ b/lib/pages/whisper_detail/controller.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'package:PiliPlus/http/loading_state.dart'; diff --git a/lib/pages/whisper_detail/view.dart b/lib/pages/whisper_detail/view.dart index 7ec4d64b..ad57e305 100644 --- a/lib/pages/whisper_detail/view.dart +++ b/lib/pages/whisper_detail/view.dart @@ -123,9 +123,7 @@ class _WhisperDetailPageState Loading() => loadingWidget, Success() => loadingState.response?.isNotEmpty == true ? refreshIndicator( - onRefresh: () async { - await _whisperDetailController.onRefresh(); - }, + onRefresh: _whisperDetailController.onRefresh, child: ListView.builder( shrinkWrap: true, reverse: true, @@ -207,7 +205,7 @@ class _WhisperDetailPageState crossAxisAlignment: CrossAxisAlignment.end, children: [ IconButton( - onPressed: () async { + onPressed: () { updatePanelType( PanelType.emoji == currentPanelType ? PanelType.keyboard diff --git a/lib/pages/whisper_detail/widget/chat_item.dart b/lib/pages/whisper_detail/widget/chat_item.dart index 99944f30..fac3ac04 100644 --- a/lib/pages/whisper_detail/widget/chat_item.dart +++ b/lib/pages/whisper_detail/widget/chat_item.dart @@ -435,7 +435,7 @@ class ChatItem extends StatelessWidget { )); case MsgType.articleCard: return GestureDetector( - onTap: () async { + onTap: () { Get.toNamed( '/articlePage', parameters: { diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index c5cd9e57..f2d9a5e2 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -395,8 +395,7 @@ class PlPlayerController { static Function? _playCallBack; - static Future playIfExists( - {bool repeat = false, bool hideControls = true}) async { + static void playIfExists({bool repeat = false, bool hideControls = true}) { // await _instance?.play(repeat: repeat, hideControls: hideControls); _playCallBack?.call(); } @@ -848,7 +847,7 @@ class PlPlayerController { // 自动播放 if (_autoPlay) { - await playIfExists(); + playIfExists(); // await play(duration: duration); } } diff --git a/lib/services/audio_handler.dart b/lib/services/audio_handler.dart index bd498af4..5c485a20 100644 --- a/lib/services/audio_handler.dart +++ b/lib/services/audio_handler.dart @@ -40,7 +40,7 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler { @override Future play() async { - await PlPlayerController.playIfExists(); + PlPlayerController.playIfExists(); // player.play(); } diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index 12ad202c..dde6f766 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -18,7 +18,7 @@ class PiliScheme { static StreamSubscription? listener; static final uriDigitRegExp = RegExp(r'/(\d+)'); - static Future init() async { + static void init() { // Register our protocol only on Windows platform // registerProtocolHandler('bilibili'); appLinks = AppLinks(); diff --git a/lib/utils/download.dart b/lib/utils/download.dart index 9eda5eba..5e566da4 100644 --- a/lib/utils/download.dart +++ b/lib/utils/download.dart @@ -50,7 +50,7 @@ class DownloadUtils { if (status == PermissionStatus.denied || status == PermissionStatus.permanentlyDenied) { if (!context.mounted) return false; - await showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( @@ -58,7 +58,7 @@ class DownloadUtils { content: const Text('存储权限未授权'), actions: [ TextButton( - onPressed: () async { + onPressed: () { openAppSettings(); }, child: const Text('去授权'), diff --git a/lib/utils/request_utils.dart b/lib/utils/request_utils.dart index 5d18ff20..866d123a 100644 --- a/lib/utils/request_utils.dart +++ b/lib/utils/request_utils.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'dart:math'; @@ -474,7 +475,7 @@ class RequestUtils { Gt3FlutterPlugin() ..addEventHandler( - onClose: (Map message) async { + onClose: (Map message) { SmartDialog.showToast('关闭验证'); }, onResult: (Map message) async { @@ -510,7 +511,7 @@ class RequestUtils { debugPrint("Captcha result code : $code"); } }, - onError: (Map message) async { + onError: (Map message) { SmartDialog.showToast("Captcha onError: $message"); String code = message["code"]; // 处理验证中返回的错误 Handling errors returned in verification diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 5a35ec25..37c64750 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -572,7 +572,7 @@ class GStorage { ..replyLengthLimit = replyLengthLimit; } - static Future exportAllSettings() async { + static String exportAllSettings() { return jsonEncode({ setting.name: setting.toMap(), video.name: video.toMap(), @@ -599,7 +599,7 @@ class GStorage { ..registerAdapter(RuleFilterAdapter()); } - static Future close() async { + static void close() { // user.compact(); // user.close(); userInfo @@ -915,7 +915,7 @@ class Accounts { } } - static Future refresh() async { + static void refresh() { for (var a in account.values) { for (var t in a.type) { accountMode[t] = a; @@ -938,7 +938,7 @@ class Accounts { // Request.buvidActive(AnonymousAccount()); } - static Future close() async { + static void close() { account ..compact() ..close(); diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index de0d7ffa..b177b774 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -57,7 +57,7 @@ class Utils { static bool? _isIpad; - static FutureOr isIpad() async { + static Future isIpad() async { if (Platform.isIOS.not) { return false; } @@ -164,11 +164,11 @@ class Utils { return '${randomTraceId.toString()}:${randomTraceId.toString().substring(16, 32)}:0:0'; } - static Future copyText( + static void copyText( String text, { bool needToast = true, String? toastText, - }) async { + }) { Clipboard.setData(ClipboardData(text: text)); if (needToast) { SmartDialog.showToast(toastText ?? '已复制');