網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
通過(guò)navigatorKey的方式?
void main() {
runApp(MyApp());
}
final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>();
class MyApp extends StatelessWidget {
MyApp() {
}
// This widget is the view.common.root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: navigatorKey,
);
}
}
跳轉(zhuǎn):
navigatorKey.currentState.pushName('跳轉(zhuǎn)url')?
fluro跳轉(zhuǎn):
AppRouteMatch match = router.match(path);
AppRoute route = match?.route;
Handler handler = route.handler;
Map<String, List<String>> parameters = match?.parameters ?? <String, List<String>>{};
navigatorKey.currentState.push(CupertinoPageRoute(builder: (BuildContext context) => handler.handlerFunc(context, parameters)));
獲取context:
Context context = navigatorKey.currentState.overlay.context
注意:通過(guò)這種方式獲取的context在某些情況下需要放在
Future.delayed(Duration(seconds: 0)).then((onValue) {
});
中使用。
原文鏈接:https://blog.csdn.net/langyalaoa/article/details/103475236
相關(guān)推薦
- 2022-09-29 基于Python3編寫一個(gè)GUI翻譯器_python
- 2022-10-22 Kotlin匿名函數(shù)使用介紹_Android
- 2022-05-20 nginx刷新頁(yè)面出現(xiàn)404解決方案(親測(cè)有效)_nginx
- 2022-12-03 c#常用表格控件dataGridView的分頁(yè)顯示_C#教程
- 2022-11-10 在React項(xiàng)目中使用TypeScript詳情_React
- 2023-01-18 高斯衰減python實(shí)現(xiàn)方式_python
- 2023-01-17 Python無(wú)權(quán)點(diǎn)文件轉(zhuǎn)化成鄰接矩陣方式_python
- 2022-06-01 docker安裝nginx并配置ssl的方法步驟_docker
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過(guò)濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支