From 148e0872b49a889f08e1f4b53c7e8b21eee7771e Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Wed, 23 Jul 2025 16:19:18 +0800 Subject: [PATCH] lint Signed-off-by: bggRGjQaUbCoE --- analysis_options.yaml | 2 +- .../cupertino/cupertino_text_field.dart | 6 +-- .../widgets/text_field/editable_text.dart | 2 +- .../widgets/text_field/spell_check.dart | 2 +- lib/common/widgets/text_field/text_field.dart | 46 +++++++++---------- lib/http/dynamics.dart | 14 +++--- lib/http/fav.dart | 10 ++-- lib/http/live.dart | 8 ++-- lib/http/login.dart | 24 +++++----- lib/http/member.dart | 12 ++--- lib/http/msg.dart | 22 ++++----- lib/http/pgc.dart | 16 +++---- lib/http/search.dart | 42 ++++++++--------- lib/http/user.dart | 10 ++-- lib/http/video.dart | 32 ++++++------- lib/pages/member_profile/view.dart | 3 +- lib/pages/video/controller.dart | 2 +- 17 files changed, 126 insertions(+), 127 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index dcc4a95b..d8d17f54 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -27,7 +27,6 @@ linter: # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule # - always_specify_types # - avoid_positional_boolean_parameters - # - use_null_aware_elements - always_declare_return_types - always_use_package_imports - avoid_empty_else @@ -53,5 +52,6 @@ linter: - use_colored_box - use_decorated_box - use_named_constants + - use_null_aware_elements # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options diff --git a/lib/common/widgets/text_field/cupertino/cupertino_text_field.dart b/lib/common/widgets/text_field/cupertino/cupertino_text_field.dart index 25063931..7b449ccb 100644 --- a/lib/common/widgets/text_field/cupertino/cupertino_text_field.dart +++ b/lib/common/widgets/text_field/cupertino/cupertino_text_field.dart @@ -1436,7 +1436,7 @@ class _CupertinoRichTextFieldState extends State children: [ // Insert a prefix at the front if the prefix visibility mode matches // the current text state. - if (prefixWidget != null) prefixWidget, + ?prefixWidget, // In the middle part, stack the placeholder on top of the main EditableText // if needed. Expanded( @@ -1448,12 +1448,12 @@ class _CupertinoRichTextFieldState extends State alignment: AlignmentDirectional.center, textDirection: widget.textDirection, children: [ - if (placeholder != null) placeholder, + ?placeholder, editableText ], ), ), - if (suffixWidget != null) suffixWidget, + ?suffixWidget, ], ); }, diff --git a/lib/common/widgets/text_field/editable_text.dart b/lib/common/widgets/text_field/editable_text.dart index 65f8f6b1..b4feb973 100644 --- a/lib/common/widgets/text_field/editable_text.dart +++ b/lib/common/widgets/text_field/editable_text.dart @@ -778,7 +778,7 @@ class EditableText extends StatefulWidget { if (_strutStyle == null) { return StrutStyle.fromTextStyle(style, forceStrutHeight: true); } - return _strutStyle!.inheritFromTextStyle(style); + return _strutStyle.inheritFromTextStyle(style); } final StrutStyle? _strutStyle; diff --git a/lib/common/widgets/text_field/spell_check.dart b/lib/common/widgets/text_field/spell_check.dart index f2b57893..699c904d 100644 --- a/lib/common/widgets/text_field/spell_check.dart +++ b/lib/common/widgets/text_field/spell_check.dart @@ -12,7 +12,7 @@ import 'package:flutter/painting.dart'; import 'package:flutter/services.dart' show SpellCheckResults, SpellCheckService, SuggestionSpan, TextEditingValue; -import 'editable_text.dart' show EditableTextContextMenuBuilder; +import 'package:PiliPlus/common/widgets/text_field/editable_text.dart' show EditableTextContextMenuBuilder; /// Controls how spell check is performed for text input. /// diff --git a/lib/common/widgets/text_field/text_field.dart b/lib/common/widgets/text_field/text_field.dart index bc96dfe4..912172a3 100644 --- a/lib/common/widgets/text_field/text_field.dart +++ b/lib/common/widgets/text_field/text_field.dart @@ -507,7 +507,7 @@ class RichTextField extends StatefulWidget { /// to its controller. When the widget gains the or loses the focus it will /// [WidgetStatesController.update] its controller's [WidgetStatesController.value] /// and notify listeners of the change. - final MaterialStatesController? statesController; + final WidgetStatesController? statesController; /// {@macro flutter.widgets.editableText.obscuringCharacter} final String obscuringCharacter; @@ -1345,10 +1345,10 @@ class RichTextFieldState extends State if (widget.statesController == oldWidget.statesController) { _statesController - ..update(MaterialState.disabled, !_isEnabled) - ..update(MaterialState.hovered, _isHovering) - ..update(MaterialState.focused, _effectiveFocusNode.hasFocus) - ..update(MaterialState.error, _hasError); + ..update(WidgetState.disabled, !_isEnabled) + ..update(WidgetState.hovered, _isHovering) + ..update(WidgetState.focused, _effectiveFocusNode.hasFocus) + ..update(WidgetState.error, _hasError); } else { oldWidget.statesController?.removeListener(_handleStatesControllerChange); if (widget.statesController != null) { @@ -1437,7 +1437,7 @@ class RichTextFieldState extends State // highlight. }); _statesController.update( - MaterialState.focused, _effectiveFocusNode.hasFocus); + WidgetState.focused, _effectiveFocusNode.hasFocus); } void _handleSelectionChanged( @@ -1487,30 +1487,30 @@ class RichTextFieldState extends State setState(() { _isHovering = hovering; }); - _statesController.update(MaterialState.hovered, _isHovering); + _statesController.update(WidgetState.hovered, _isHovering); } } // Material states controller. - MaterialStatesController? _internalStatesController; + WidgetStatesController? _internalStatesController; void _handleStatesControllerChange() { // Force a rebuild to resolve MaterialStateProperty properties. setState(() {}); } - MaterialStatesController get _statesController => + WidgetStatesController get _statesController => widget.statesController ?? _internalStatesController!; void _initStatesController() { if (widget.statesController == null) { - _internalStatesController = MaterialStatesController(); + _internalStatesController = WidgetStatesController(); } - _statesController.update(MaterialState.disabled, !_isEnabled); - _statesController.update(MaterialState.hovered, _isHovering); + _statesController.update(WidgetState.disabled, !_isEnabled); + _statesController.update(WidgetState.hovered, _isHovering); _statesController.update( - MaterialState.focused, _effectiveFocusNode.hasFocus); - _statesController.update(MaterialState.error, _hasError); + WidgetState.focused, _effectiveFocusNode.hasFocus); + _statesController.update(WidgetState.error, _hasError); _statesController.addListener(_handleStatesControllerChange); } @@ -1543,14 +1543,14 @@ class RichTextFieldState extends State TextStyle _getInputStyleForState(TextStyle style) { final ThemeData theme = Theme.of(context); - final TextStyle stateStyle = MaterialStateProperty.resolveAs( + final TextStyle stateStyle = WidgetStateProperty.resolveAs( theme.useMaterial3 ? _m3StateInputStyle(context)! : _m2StateInputStyle(context)!, _statesController.value, ); final TextStyle providedStyle = - MaterialStateProperty.resolveAs(style, _statesController.value); + WidgetStateProperty.resolveAs(style, _statesController.value); return providedStyle.merge(stateStyle); } @@ -1570,7 +1570,7 @@ class RichTextFieldState extends State final ThemeData theme = Theme.of(context); final DefaultSelectionStyle selectionStyle = DefaultSelectionStyle.of(context); - final TextStyle? providedStyle = MaterialStateProperty.resolveAs( + final TextStyle? providedStyle = WidgetStateProperty.resolveAs( widget.style, _statesController.value, ); @@ -1828,8 +1828,8 @@ class RichTextFieldState extends State ); } final MouseCursor effectiveMouseCursor = - MaterialStateProperty.resolveAs( - widget.mouseCursor ?? MaterialStateMouseCursor.textable, + WidgetStateProperty.resolveAs( + widget.mouseCursor ?? WidgetStateMouseCursor.textable, _statesController.value, ); @@ -1918,9 +1918,9 @@ class RichTextFieldState extends State } TextStyle? _m2StateInputStyle(BuildContext context) => - MaterialStateTextStyle.resolveWith((Set states) { + WidgetStateTextStyle.resolveWith((Set states) { final ThemeData theme = Theme.of(context); - if (states.contains(MaterialState.disabled)) { + if (states.contains(WidgetState.disabled)) { return TextStyle(color: theme.disabledColor); } return TextStyle(color: theme.textTheme.titleMedium?.color); @@ -1940,8 +1940,8 @@ TextStyle _m2CounterErrorStyle(BuildContext context) => Theme.of(context) // dart format off TextStyle? _m3StateInputStyle(BuildContext context) => - MaterialStateTextStyle.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) { + WidgetStateTextStyle.resolveWith((Set states) { + if (states.contains(WidgetState.disabled)) { return TextStyle( color: Theme.of(context) .textTheme diff --git a/lib/http/dynamics.dart b/lib/http/dynamics.dart index a506b5b9..c25b9d7a 100644 --- a/lib/http/dynamics.dart +++ b/lib/http/dynamics.dart @@ -158,8 +158,8 @@ class DynamicsHttp { }, if (privatePub != null || replyOption != null || publishTime != null) "option": { - if (privatePub != null) 'private_pub': privatePub, - if (publishTime != null) "timer_pub_time": publishTime, + 'private_pub': ?privatePub, + "timer_pub_time": ?publishTime, if (replyOption == ReplyOptionType.close) "close_comment": 1 else if (replyOption == ReplyOptionType.choose) @@ -172,7 +172,7 @@ class DynamicsHttp { : pics != null ? 2 : 1, - if (pics != null) 'pics': pics, + 'pics': ?pics, "attach_card": attachCard, "upload_id": "${rid != null ? 0 : mid}_${DateTime.now().millisecondsSinceEpoch ~/ 1000}_${Utils.random.nextInt(9000) + 1000}", @@ -189,7 +189,7 @@ class DynamicsHttp { }, if (dynIdStr != null || rid != null) "web_repost_src": { - if (dynIdStr != null) "dyn_id_str": dynIdStr, + "dyn_id_str": ?dynIdStr, if (rid != null) "revs_id": { "dyn_type": dynType, @@ -222,9 +222,9 @@ class DynamicsHttp { Api.dynamicDetail, queryParameters: { 'timezone_offset': -480, - if (id != null) 'id': id, - if (rid != null) 'rid': rid, - if (type != null) 'type': type, + 'id': ?id, + 'rid': ?rid, + 'type': ?type, 'features': 'itemOpusStyle', 'gaia_source': 'Athena', 'web_location': '333.1330', diff --git a/lib/http/fav.dart b/lib/http/fav.dart index 47db3d9c..21f6a6ca 100644 --- a/lib/http/fav.dart +++ b/lib/http/fav.dart @@ -342,7 +342,7 @@ class FavHttp { queryParameters: { 'vmid': mid, 'type': type, - if (followStatus != null) 'follow_status': followStatus, + 'follow_status': ?followStatus, 'pn': pn, }, ); @@ -475,7 +475,7 @@ class FavHttp { 'privacy': privacy, 'cover': cover.isNotEmpty ? Uri.encodeFull(cover) : cover, 'csrf': Accounts.main.csrf, - if (mediaId != null) 'media_id': mediaId, + 'media_id': ?mediaId, }, options: Options( contentType: Headers.formUrlEncodedContentType, @@ -650,9 +650,9 @@ class FavHttp { ? Api.copyToview : Api.moveToview, data: { - if (srcMediaId != null) 'src_media_id': srcMediaId, + 'src_media_id': ?srcMediaId, 'tar_media_id': tarMediaId, - if (mid != null) 'mid': mid, + 'mid': ?mid, 'resources': resources.join(','), 'platform': 'web', 'csrf': Accounts.main.csrf, @@ -689,7 +689,7 @@ class FavHttp { queryParameters: { 'up_mid': mid, 'rid': rid, - if (type != null) 'type': type, + 'type': ?type, }, ); if (res.data['code'] == 0) { diff --git a/lib/http/live.dart b/lib/http/live.dart index bf17b932..f66ec90b 100644 --- a/lib/http/live.dart +++ b/lib/http/live.dart @@ -31,7 +31,7 @@ class LiveHttp { 'msg': msg, 'color': 16777215, 'mode': 1, - if (dmType != null) 'dm_type': dmType, + 'dm_type': ?dmType, if (emoticonOptions != null) 'emoticonOptions': emoticonOptions else ...{ @@ -228,8 +228,8 @@ class LiveHttp { if (isLogin) 'access_key': Accounts.main.accessKey, 'appkey': Constants.appKey, 'actionKey': 'appkey', - if (areaId != null) 'area_id': areaId, - if (parentAreaId != null) 'parent_area_id': parentAreaId, + 'area_id': ?areaId, + 'parent_area_id': ?parentAreaId, 'build': '8430300', 'c_locale': 'zh_CN', 'device': 'pad', @@ -245,7 +245,7 @@ class LiveHttp { 'page_size': '20', 'platform': 'android', 'qn': '0', - if (sortType != null) 'sort_type': sortType, + 'sort_type': ?sortType, 'tag_version': '1', 's_locale': 'zh_CN', 'scale': '2', diff --git a/lib/http/login.dart b/lib/http/login.dart index 9dd84221..7bea5fc0 100644 --- a/lib/http/login.dart +++ b/lib/http/login.dart @@ -102,16 +102,16 @@ class LoginHttp { 'cid': cid, // if (deviceTouristId != null) 'device_tourist_id': deviceTouristId, 'disable_rcmd': '0', - if (geeChallenge != null) 'gee_challenge': geeChallenge, - if (geeSeccode != null) 'gee_seccode': geeSeccode, - if (geeValidate != null) 'gee_validate': geeValidate, + 'gee_challenge': ?geeChallenge, + 'gee_seccode': ?geeSeccode, + 'gee_validate': ?geeValidate, 'local_id': buvid, // https://chinggg.github.io/post/appre/ 'login_session_id': md5.convert(utf8.encode(buvid + timestamp.toString())).toString(), 'mobi_app': 'android_hd', 'platform': 'android', - if (recaptchaToken != null) 'recaptcha_token': recaptchaToken, + 'recaptcha_token': ?recaptchaToken, 's_locale': 'zh_CN', 'statistics': Constants.statistics, 'tel': tel, @@ -211,15 +211,15 @@ class LoginHttp { .base64), 'from_pv': 'main.homepage.avatar-nologin.all.click', 'from_url': Uri.encodeComponent('bilibili://pegasus/promo'), - if (geeChallenge != null) 'gee_challenge': geeChallenge, - if (geeSeccode != null) 'gee_seccode': geeSeccode, - if (geeValidate != null) 'gee_validate': geeValidate, + 'gee_challenge': ?geeChallenge, + 'gee_seccode': ?geeSeccode, + 'gee_validate': ?geeValidate, 'local_id': buvid, //LoginUtils.generateBuvid(), 'mobi_app': 'android_hd', 'password': passwordEncrypted, 'permission': 'ALL', 'platform': 'android', - if (recaptchaToken != null) 'recaptcha_token': recaptchaToken, + 'recaptcha_token': ?recaptchaToken, 's_locale': 'zh_CN', 'statistics': Constants.statistics, 'ts': (DateTime.now().millisecondsSinceEpoch ~/ 1000).toString(), @@ -365,10 +365,10 @@ class LoginHttp { 'disable_rcmd': '0', 'sms_type': smsType ?? 'loginTelCheck', 'tmp_code': tmpCode, - if (geeChallenge != null) 'gee_challenge': geeChallenge, - if (geeSeccode != null) 'gee_seccode': geeSeccode, - if (geeValidate != null) 'gee_validate': geeValidate, - if (recaptchaToken != null) 'recaptcha_token': recaptchaToken, + 'gee_challenge': ?geeChallenge, + 'gee_seccode': ?geeSeccode, + 'gee_validate': ?geeValidate, + 'recaptcha_token': ?recaptchaToken, }; AppSign.appSign(data); var res = await Request().post( diff --git a/lib/http/member.dart b/lib/http/member.dart index 5a2942aa..9f930aec 100644 --- a/lib/http/member.dart +++ b/lib/http/member.dart @@ -40,7 +40,7 @@ class MemberHttp { { 'mid': mid, 'reason': reason, - if (reasonV2 != null) 'reason_v2': reasonV2, + 'reason_v2': ?reasonV2, 'csrf': Accounts.main.csrf, }, ), @@ -131,8 +131,8 @@ class MemberHttp { if (seasonId != null) 'season_id': seasonId.toString(), if (seriesId != null) 'series_id': seriesId.toString(), 'qn': type == ContributeType.video ? '80' : '32', - if (order != null) 'order': order, - if (sort != null) 'sort': sort, + 'order': ?order, + 'sort': ?sort, if (includeCursor != null) 'include_cursor': includeCursor.toString(), 'statistics': Constants.statisticsApp, 'vmid': mid.toString(), @@ -235,7 +235,7 @@ class MemberHttp { 'mobi_app': 'android', 'platform': 'android', 's_locale': 'zh_CN', - if (fromViewAid != null) 'from_view_aid': fromViewAid, + 'from_view_aid': ?fromViewAid, 'statistics': Constants.statisticsApp, 'vmid': mid.toString(), }; @@ -336,7 +336,7 @@ class MemberHttp { 'ps': ps, 'tid': tid, 'pn': pn, - if (keyword != null) 'keyword': keyword, + 'keyword': ?keyword, 'order': order, 'platform': 'web', 'web_location': '1550101', @@ -704,7 +704,7 @@ class MemberHttp { 'up_mid': upMid, 'pn': page, 'ps': 100, - if (privilegeType != null) 'privilege_type': privilegeType, + 'privilege_type': ?privilegeType, 'mobi_app': 'web', 'web_location': 333.1196, if (Accounts.main.isLogin) 'csrf': Accounts.main.csrf, diff --git a/lib/http/msg.dart b/lib/http/msg.dart index 3cfc66c9..0d05bc96 100644 --- a/lib/http/msg.dart +++ b/lib/http/msg.dart @@ -26,8 +26,8 @@ class MsgHttp { var res = await Request().get( Api.msgFeedReply, queryParameters: { - if (cursor != null) 'id': cursor, - if (cursorTime != null) 'reply_time': cursorTime, + 'id': ?cursor, + 'reply_time': ?cursorTime, 'platform': 'web', 'mobi_app': 'web', 'build': 0, @@ -46,8 +46,8 @@ class MsgHttp { var res = await Request().get( Api.msgFeedAt, queryParameters: { - if (cursor != null) 'id': cursor, - if (cursorTime != null) 'at_time': cursorTime, + 'id': ?cursor, + 'at_time': ?cursorTime, 'platform': 'web', 'mobi_app': 'web', 'build': 0, @@ -64,8 +64,8 @@ class MsgHttp { static Future> msgFeedLikeMe( {int? cursor, int? cursorTime}) async { var res = await Request().get(Api.msgFeedLike, queryParameters: { - if (cursor != null) 'id': cursor, - if (cursorTime != null) 'like_time': cursorTime, + 'id': ?cursor, + 'like_time': ?cursorTime, 'platform': 'web', 'mobi_app': 'web', 'build': 0, @@ -106,7 +106,7 @@ class MsgHttp { var res = await Request().get( Api.msgSysNotify, queryParameters: { - if (cursor != null) 'cursor': cursor, + 'cursor': ?cursor, 'page_size': pageSize, 'mobi_app': 'web', 'build': 0, @@ -176,8 +176,8 @@ class MsgHttp { final file = await MultipartFile.fromFile(path); Map data = { 'file_up': file, - if (category != null) 'category': category, - if (biz != null) 'biz': biz, + 'category': ?category, + 'biz': ?biz, 'csrf': Accounts.main.csrf, }; var res = await Request().post( @@ -233,8 +233,8 @@ class MsgHttp { }, data: { "dyn_id_str": dynIdStr, - if (dynType != null) "dyn_type": dynType, - if (ridStr != null) "rid_str": ridStr, + "dyn_type": ?dynType, + "rid_str": ?ridStr, }, ); if (res.data['code'] == 0) { diff --git a/lib/http/pgc.dart b/lib/http/pgc.dart index 6f431eb3..83f40bae 100644 --- a/lib/http/pgc.dart +++ b/lib/http/pgc.dart @@ -23,9 +23,9 @@ class PgcHttp { Api.pgcIndexResult, queryParameters: { ...params, - if (seasonType != null) 'season_type': seasonType, - if (type != null) 'type': type, - if (indexType != null) 'index_type': indexType, + 'season_type': ?seasonType, + 'type': ?type, + 'index_type': ?indexType, 'page': page, 'pagesize': 21, }, @@ -45,9 +45,9 @@ class PgcHttp { var res = await Request().get( Api.pgcIndexCondition, queryParameters: { - if (seasonType != null) 'season_type': seasonType, - if (type != null) 'type': type, - if (indexType != null) 'index_type': indexType, + 'season_type': ?seasonType, + 'type': ?type, + 'index_type': ?indexType, }, ); if (res.data['code'] == 0) { @@ -65,7 +65,7 @@ class PgcHttp { Api.pgcIndex, queryParameters: { 'page': page, - if (indexType != null) 'index_type': indexType, + 'index_type': ?indexType, }, ); if (res.data['code'] == 0) { @@ -107,7 +107,7 @@ class PgcHttp { 'media_id': mediaId, 'ps': 20, 'sort': sort, - if (next != null) 'cursor': next, + 'cursor': ?next, 'web_location': 666.19, }, ); diff --git a/lib/http/search.dart b/lib/http/search.dart index 6dfced17..6f1a8bb3 100644 --- a/lib/http/search.dart +++ b/lib/http/search.dart @@ -59,13 +59,13 @@ class SearchHttp { 'keyword': keyword, 'page': page, if (order?.isNotEmpty == true) 'order': order, - if (duration != null) 'duration': duration, - if (tids != null) 'tids': tids, - if (orderSort != null) 'order_sort': orderSort, - if (userType != null) 'user_type': userType, - if (categoryId != null) 'category_id': categoryId, - if (pubBegin != null) 'pubtime_begin_s': pubBegin, - if (pubEnd != null) 'pubtime_end_s': pubEnd, + 'duration': ?duration, + 'tids': ?tids, + 'order_sort': ?orderSort, + 'user_type': ?userType, + 'category_id': ?categoryId, + 'pubtime_begin_s': ?pubBegin, + 'pubtime_end_s': ?pubEnd, }; var res = await Request().get( Api.searchByType, @@ -126,13 +126,13 @@ class SearchHttp { 'keyword': keyword, 'page': page, if (order?.isNotEmpty == true) 'order': order, - if (duration != null) 'duration': duration, - if (tids != null) 'tids': tids, - if (orderSort != null) 'order_sort': orderSort, - if (userType != null) 'user_type': userType, - if (categoryId != null) 'category_id': categoryId, - if (pubBegin != null) 'pubtime_begin_s': pubBegin, - if (pubEnd != null) 'pubtime_end_s': pubEnd, + 'duration': ?duration, + 'tids': ?tids, + 'order_sort': ?orderSort, + 'user_type': ?userType, + 'category_id': ?categoryId, + 'pubtime_begin_s': ?pubBegin, + 'pubtime_end_s': ?pubEnd, }; var res = await Request().get( Api.searchAll, @@ -157,8 +157,8 @@ class SearchHttp { var res = await Request().get( Api.ab2c, queryParameters: { - if (aid != null) 'aid': aid, - if (bvid != null) 'bvid': bvid, + 'aid': ?aid, + 'bvid': ?bvid, }, ); if (res.data['code'] == 0) { @@ -180,8 +180,8 @@ class SearchHttp { var res = await Request().get( Api.pgcInfo, queryParameters: { - if (seasonId != null) 'season_id': seasonId, - if (epId != null) 'ep_id': epId, + 'season_id': ?seasonId, + 'ep_id': ?epId, }, ); if (res.data['code'] == 0) { @@ -195,7 +195,7 @@ class SearchHttp { var res = await Request().get( Api.episodeInfo, queryParameters: { - if (epId != null) 'ep_id': epId, + 'ep_id': ?epId, }, ); if (res.data['code'] == 0) { @@ -212,8 +212,8 @@ class SearchHttp { var res = await Request().get( Api.pgcInfo, queryParameters: { - if (seasonId != null) 'season_id': seasonId, - if (epId != null) 'ep_id': epId, + 'season_id': ?seasonId, + 'ep_id': ?epId, }, ); if (res.data['code'] == 0) { diff --git a/lib/http/user.dart b/lib/http/user.dart index 63b6aa07..e78f13d2 100644 --- a/lib/http/user.dart +++ b/lib/http/user.dart @@ -135,8 +135,8 @@ class UserHttp { var res = await Request().post( Api.toViewLater, queryParameters: { - if (aid != null) 'aid': aid, - if (bvid != null) 'bvid': bvid, + 'aid': ?aid, + 'bvid': ?bvid, 'csrf': Accounts.main.csrf, }, ); @@ -189,7 +189,7 @@ class UserHttp { var res = await Request().post( Api.toViewClear, queryParameters: { - if (cleanType != null) 'clean_type': cleanType, + 'clean_type': ?cleanType, 'csrf': Accounts.main.csrf, }, ); @@ -305,8 +305,8 @@ class UserHttp { 'mobi_app': 'web', 'type': type, 'biz_id': bizId, - if (oid != null) 'oid': oid, - if (otype != null) 'otype': otype, // ugc:2 // pgc: 24 + 'oid': ?oid, + 'otype': ?otype, // ugc:2 // pgc: 24 'ps': ps, 'direction': direction, 'desc': desc, diff --git a/lib/http/video.dart b/lib/http/video.dart index 1ff9e434..66fa2b0f 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -188,10 +188,10 @@ class VideoHttp { bool? forcePgcApi, }) async { final params = await WbiSign.makSign({ - if (avid != null) 'avid': avid, - if (bvid != null) 'bvid': bvid, - if (epid != null) 'ep_id': epid, - if (seasonId != null) 'season_id': seasonId, + 'avid': ?avid, + 'bvid': ?bvid, + 'ep_id': ?epid, + 'season_id': ?seasonId, 'cid': cid, 'qn': qn ?? 80, // 获取所有格式的视频 @@ -444,8 +444,8 @@ class VideoHttp { var res = await Request().get(Api.feedDislike, queryParameters: { 'goto': goto, 'id': id, - if (reasonId != null) 'reason_id': reasonId, - if (feedbackId != null) 'feedback_id': feedbackId, + 'reason_id': ?reasonId, + 'feedback_id': ?feedbackId, 'build': '1', 'mobi_app': 'android', }); @@ -468,8 +468,8 @@ class VideoHttp { var res = await Request().get(Api.feedDislikeCancel, queryParameters: { 'goto': goto, 'id': id, - if (reasonId != null) 'reason_id': reasonId, - if (feedbackId != null) 'feedback_id': feedbackId, + 'reason_id': ?reasonId, + 'feedback_id': ?feedbackId, 'build': '1', 'mobi_app': 'android', }); @@ -604,8 +604,8 @@ class VideoHttp { type, }) async { await Request().post(Api.historyReport, queryParameters: { - if (aid != null) 'aid': aid, - if (type != null) 'type': type, + 'aid': ?aid, + 'type': ?type, 'csrf': Accounts.main.csrf, }); } @@ -622,10 +622,10 @@ class VideoHttp { await Request().post(Api.heartBeat, queryParameters: { 'bvid': bvid, 'cid': cid, - if (epid != null) 'epid': epid, - if (seasonId != null) 'sid': seasonId, + 'epid': ?epid, + 'sid': ?seasonId, if (epid != null) 'type': 4, - if (subType != null) 'sub_type': subType, + 'sub_type': ?subType, 'played_time': progress, 'csrf': Accounts.main.csrf, }); @@ -747,8 +747,8 @@ class VideoHttp { var res = await Request().get( Api.playInfo, queryParameters: { - if (aid != null) 'aid': aid, - if (bvid != null) 'bvid': bvid, + 'aid': ?aid, + 'bvid': ?bvid, 'cid': cid, }, ); @@ -873,7 +873,7 @@ class VideoHttp { 'oid_type': 0, 'pn': page, 'ps': 10, - if (uperMid != null) 'uper_mid': uperMid, + 'uper_mid': ?uperMid, }, ); if (res.data['code'] == 0) { diff --git a/lib/pages/member_profile/view.dart b/lib/pages/member_profile/view.dart index 46f06dc4..7af0c448 100644 --- a/lib/pages/member_profile/view.dart +++ b/lib/pages/member_profile/view.dart @@ -446,8 +446,7 @@ class _EditProfilePageState extends State { ), ), ) - else if (widget != null) - widget, + else ?widget, if (needIcon) Icon( Icons.keyboard_arrow_right, diff --git a/lib/pages/video/controller.dart b/lib/pages/video/controller.dart index 79fa1b4b..69250552 100644 --- a/lib/pages/video/controller.dart +++ b/lib/pages/video/controller.dart @@ -1415,7 +1415,7 @@ class VideoDetailController extends GetxController queryParameters: { 'bvid': bvid, 'graph_version': graphVersion, - if (edgeId != null) 'edge_id': edgeId, + 'edge_id': ?edgeId, }, ); if (res.data['code'] == 0) {