opt: unnecessary_non_null_assertion (#1762)

This commit is contained in:
My-Responsitories
2025-12-03 17:35:42 +08:00
committed by GitHub
parent b7a277a57c
commit 2b3ec77e92
89 changed files with 249 additions and 247 deletions

View File

@@ -1879,17 +1879,17 @@ class VideoDetailController extends GetxController
}
}
}
if (episodes?.isNotEmpty == true) {
if (episodes != null && episodes.isNotEmpty) {
final downloadService = Get.find<DownloadService>();
await downloadService.waitForInitialization;
if (!context.mounted) {
return;
}
final Set<int?> cidSet =
(downloadService.downloadList + downloadService.waitDownloadQueue)
.map((e) => e.cid)
.toSet();
final index = episodes!.indexWhere(
final Set<int> cidSet = downloadService.downloadList
.followedBy(downloadService.waitDownloadQueue)
.map((e) => e.cid)
.toSet();
final index = episodes.indexWhere(
(e) => e.cid == (seasonCid ?? cid.value),
);
final size = context.mediaQuerySize;

View File

@@ -346,9 +346,9 @@ class _PgcIntroPageState extends State<PgcIntroPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(name),
if (role?.isNotEmpty == true)
if (role != null && role.isNotEmpty)
Text(
role!,
role,
style: TextStyle(
fontSize: 12,
color: theme.colorScheme.outline,

View File

@@ -133,11 +133,11 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
// 获取up主粉丝数
Future<void> queryUserStat(List<Staff>? staff) async {
if (staff?.isNotEmpty == true) {
if (staff != null && staff.isNotEmpty) {
Request()
.get(
Api.relations,
queryParameters: {'fids': staff!.map((item) => item.mid).join(',')},
queryParameters: {'fids': staff.map((item) => item.mid).join(',')},
)
.then((res) {
if (res.data['code'] == 0) {

View File

@@ -196,7 +196,7 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
itemExtent: 100,
),
Success(:var response) =>
response?.isNotEmpty == true
response != null && response.isNotEmpty
? SliverFixedExtentList.builder(
itemBuilder: (context, index) {
if (index == response.length - 1 && _controller.hasNext) {
@@ -221,7 +221,7 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
),
);
},
itemCount: response!.length,
itemCount: response.length,
itemExtent: 100,
)
: HttpError(onReload: _controller.onReload),

View File

@@ -187,7 +187,7 @@ class _NoteListPageState extends State<NoteListPage>
itemCount: 8,
),
Success(:var response) =>
response?.isNotEmpty == true
response != null && response.isNotEmpty
? SliverList.separated(
itemBuilder: (context, index) {
if (index == response.length - 1) {
@@ -195,7 +195,7 @@ class _NoteListPageState extends State<NoteListPage>
}
return _itemWidget(theme, response[index]);
},
itemCount: response!.length,
itemCount: response.length,
separatorBuilder: (context, index) => divider,
)
: HttpError(onReload: _controller.onReload),

View File

@@ -33,7 +33,7 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel> with GridMixin {
return switch (loadingState) {
Loading() => gridSkeleton,
Success(:var response) =>
response?.isNotEmpty == true
response != null && response.isNotEmpty
? SliverGrid.builder(
gridDelegate: gridDelegate,
itemBuilder: (context, index) {
@@ -44,7 +44,7 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel> with GridMixin {
..refresh(),
);
},
itemCount: response!.length,
itemCount: response.length,
)
: const SliverToBoxAdapter(),
Error(:var errMsg) => HttpError(

View File

@@ -53,7 +53,7 @@ class _ReplySearchChildPageState extends State<ReplySearchChildPage>
return switch (loadingState) {
Loading() => gridSkeleton,
Success(:var response) =>
response?.isNotEmpty == true
response != null && response.isNotEmpty
? SliverGrid.builder(
gridDelegate: gridDelegate,
itemBuilder: (context, index) {
@@ -65,7 +65,7 @@ class _ReplySearchChildPageState extends State<ReplySearchChildPage>
type: widget.searchType,
);
},
itemCount: response!.length,
itemCount: response.length,
)
: HttpError(onReload: _controller.onReload),
Error(:var errMsg) => HttpError(