opt: common ctr

opt: state

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-11 12:21:42 +08:00
parent 5bff1747e6
commit 574bf861f0
129 changed files with 1065 additions and 1058 deletions

View File

@@ -47,7 +47,7 @@ class LiveSearchChildController
Future<LoadingState<LiveSearchData>> customGetData() {
return LiveHttp.liveSearch(
isLogin: isLogin,
page: currentPage,
page: page,
keyword: controller.editingController.text,
type: searchType,
);

View File

@@ -91,7 +91,7 @@ class _LiveSearchChildPageState extends State<LiveSearchChildPage>
Widget _buildBody(LoadingState<List?> loadingState) {
return switch (loadingState) {
Loading() => _buildLoading,
Success() => loadingState.response?.isNotEmpty == true
Success(:var response) => response?.isNotEmpty == true
? Builder(
builder: (context) {
return switch (widget.searchType) {
@@ -106,14 +106,14 @@ class _LiveSearchChildPageState extends State<LiveSearchChildPage>
),
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == loadingState.response!.length - 1) {
if (index == response.length - 1) {
_controller.onLoadMore();
}
return LiveCardVSearch(
item: loadingState.response![index],
item: response[index],
);
},
childCount: loadingState.response!.length,
childCount: response!.length,
),
),
LiveSearchType.user => SliverGrid(
@@ -123,14 +123,14 @@ class _LiveSearchChildPageState extends State<LiveSearchChildPage>
),
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
if (index == loadingState.response!.length - 1) {
if (index == response.length - 1) {
_controller.onLoadMore();
}
return LiveSearchUserItem(
item: loadingState.response![index],
item: response[index],
);
},
childCount: loadingState.response!.length,
childCount: response!.length,
),
),
};
@@ -139,8 +139,8 @@ class _LiveSearchChildPageState extends State<LiveSearchChildPage>
: HttpError(
onReload: _controller.onReload,
),
Error() => HttpError(
errMsg: loadingState.errMsg,
Error(:var errMsg) => HttpError(
errMsg: errMsg,
onReload: _controller.onReload,
),
};