修复切换失败
This commit is contained in:
@@ -18,35 +18,14 @@ import 'package:vbvs_app/pages/mh_page/new_mine_page.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart';
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as edm;
|
||||
|
||||
// class MainPageBBottomChange extends StatefulWidget {
|
||||
// // 全局 key,用于静态访问 _HomePageState
|
||||
// static final GlobalKey<_HomePageState> globalKey =
|
||||
// GlobalKey<_HomePageState>();
|
||||
|
||||
// MainPageBBottomChange({Key? key}) : super(key: globalKey);
|
||||
|
||||
// // 静态方法:外部调用,跳转 tab
|
||||
// static void jumpTo(int index) {
|
||||
// final state = globalKey.currentState;
|
||||
// if (state != null) {
|
||||
// state.switchTab(index);
|
||||
// }
|
||||
// }
|
||||
|
||||
// static int? getCurrentIndex() {
|
||||
// final state = globalKey.currentState;
|
||||
// return state?.selectedIndex;
|
||||
// }
|
||||
|
||||
// @override
|
||||
// _HomePageState createState() => _HomePageState();
|
||||
// }
|
||||
class MainPageBBottomChange extends StatefulWidget {
|
||||
final GlobalKey<_HomePageState>? externalKey;
|
||||
// 全局 key,用于静态访问 _HomePageState
|
||||
static final GlobalKey<_HomePageState> globalKey =
|
||||
GlobalKey<_HomePageState>();
|
||||
|
||||
MainPageBBottomChange({Key? key, this.externalKey})
|
||||
: super(key: key ?? externalKey);
|
||||
MainPageBBottomChange({Key? key}) : super(key: globalKey);
|
||||
|
||||
// 静态方法:外部调用,跳转 tab
|
||||
static void jumpTo(int index) {
|
||||
final state = globalKey.currentState;
|
||||
if (state != null) {
|
||||
@@ -59,12 +38,33 @@ class MainPageBBottomChange extends StatefulWidget {
|
||||
return state?.selectedIndex;
|
||||
}
|
||||
|
||||
static final GlobalKey<_HomePageState> globalKey =
|
||||
GlobalKey<_HomePageState>();
|
||||
|
||||
@override
|
||||
_HomePageState createState() => _HomePageState();
|
||||
}
|
||||
// class MainPageBBottomChange extends StatefulWidget {
|
||||
// final GlobalKey<_HomePageState>? externalKey;
|
||||
|
||||
// MainPageBBottomChange({Key? key, this.externalKey})
|
||||
// : super(key: key ?? externalKey);
|
||||
|
||||
// static void jumpTo(int index) {
|
||||
// final state = globalKey.currentState;
|
||||
// if (state != null) {
|
||||
// state.switchTab(index);
|
||||
// }
|
||||
// }
|
||||
|
||||
// static int? getCurrentIndex() {
|
||||
// final state = globalKey.currentState;
|
||||
// return state?.selectedIndex;
|
||||
// }
|
||||
|
||||
// static final GlobalKey<_HomePageState> globalKey =
|
||||
// GlobalKey<_HomePageState>();
|
||||
|
||||
// @override
|
||||
// _HomePageState createState() => _HomePageState();
|
||||
// }
|
||||
|
||||
class _HomePageState extends State<MainPageBBottomChange>
|
||||
with SingleTickerProviderStateMixin {
|
||||
|
||||
Reference in New Issue
Block a user