mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: try-catch get dyn ctr
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -39,8 +39,14 @@ class DynamicsController extends GetxController
|
|||||||
late int currentMid = -1;
|
late int currentMid = -1;
|
||||||
late bool showLiveItems = GStorage.expandDynLivePanel;
|
late bool showLiveItems = GStorage.expandDynLivePanel;
|
||||||
|
|
||||||
DynamicsTabController get controller => Get.find<DynamicsTabController>(
|
DynamicsTabController? get controller {
|
||||||
|
try {
|
||||||
|
return Get.find<DynamicsTabController>(
|
||||||
tag: tabsConfig[tabController.index]['tag']);
|
tag: tabsConfig[tabController.index]['tag']);
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@@ -171,7 +177,7 @@ class DynamicsController extends GetxController
|
|||||||
if (mid == -1) {
|
if (mid == -1) {
|
||||||
queryFollowUp();
|
queryFollowUp();
|
||||||
}
|
}
|
||||||
controller.onReload();
|
controller?.onReload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,20 +188,20 @@ class DynamicsController extends GetxController
|
|||||||
@override
|
@override
|
||||||
Future<void> onRefresh() async {
|
Future<void> onRefresh() async {
|
||||||
queryFollowUp();
|
queryFollowUp();
|
||||||
await controller.onRefresh();
|
await controller?.onRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> animateToTop() async {
|
Future<void> animateToTop() async {
|
||||||
controller.animateToTop();
|
controller?.animateToTop();
|
||||||
scrollController.animToTop();
|
scrollController.animToTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void toTopOrRefresh() {
|
void toTopOrRefresh() {
|
||||||
final ctr = controller;
|
final ctr = controller;
|
||||||
if (ctr.scrollController.hasClients) {
|
if (ctr?.scrollController.hasClients == true) {
|
||||||
if (ctr.scrollController.position.pixels == 0) {
|
if (ctr!.scrollController.position.pixels == 0) {
|
||||||
if (scrollController.hasClients &&
|
if (scrollController.hasClients &&
|
||||||
scrollController.position.pixels != 0) {
|
scrollController.position.pixels != 0) {
|
||||||
scrollController.animToTop();
|
scrollController.animToTop();
|
||||||
|
|||||||
Reference in New Issue
Block a user