mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-12 21:17:41 +08:00
@@ -11,6 +11,7 @@ import 'package:PiliPlus/models_new/pgc/pgc_info_model/result.dart';
|
||||
import 'package:PiliPlus/models_new/search/search_rcmd/data.dart';
|
||||
import 'package:PiliPlus/models_new/search/search_trending/data.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_detail/dimension.dart';
|
||||
import 'package:PiliPlus/utils/extension/iterable_ext.dart';
|
||||
import 'package:PiliPlus/utils/request_utils.dart';
|
||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
@@ -191,7 +192,7 @@ abstract final class SearchHttp {
|
||||
if (res.data['code'] == 0) {
|
||||
if (res.data['data'] case List list) {
|
||||
final target = part != null
|
||||
? (list.elementAtOrNull(part - 1) ?? list.firstOrNull)
|
||||
? (list.getOrNull(part - 1) ?? list.firstOrNull)
|
||||
: list.firstOrNull;
|
||||
if (target != null) {
|
||||
return (
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_detail/media.dart';
|
||||
import 'package:PiliPlus/pages/fav_detail/controller.dart';
|
||||
import 'package:PiliPlus/pages/fav_detail/widget/fav_video_card.dart';
|
||||
import 'package:PiliPlus/utils/extension/iterable_ext.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -86,8 +87,8 @@ class _FavSortPageState extends State<FavSortPage> {
|
||||
}
|
||||
|
||||
final oldItem = sortList[oldIndex];
|
||||
final newItem = sortList.elementAtOrNull(
|
||||
oldIndex > newIndex ? newIndex - 1 : newIndex,
|
||||
final newItem = sortList.getOrNull(
|
||||
oldIndex > newIndex ? newIndex - 1 : newIndex, // might be Negative
|
||||
);
|
||||
sort.add(
|
||||
'${newItem == null ? '0:0' : '${newItem.id}:${newItem.type}'}:${oldItem.id}:${oldItem.type}',
|
||||
|
||||
@@ -66,4 +66,9 @@ extension ListExt<T> on List<T> {
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
T? getOrNull(int index) {
|
||||
if (index < 0 || index >= length) return null;
|
||||
return elementAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user