簡體   English   中英

Flutter App添加GetX后context中找不到GoRouter

[英]No GoRouter found in context after adding GetX in Flutter App

嘗試在我的 Flutter 應用程序中導航時,我得到以下應用程序。

到目前為止,它按預期工作:選擇正確路由的按鈕。

但是,我需要一種從 main() 到 go 到基於深度鏈接事件的路由的方法。 但是因為沒有上下文,我使用 GetX package 添加了路由。

我怎么得到這個:

Unhandled Exception: 'package:go_router/src/go_router.dart': Failed assertion: line 146 pos 12: 'inherited != null': No GoRouter found in context

我猜 GetX 和 GoRouter 路由之間存在沖突……?

如果是這樣,關於在 main() 中滿足條件時如何路由的建議?

我在這里寫了更多細節以及我的代碼: How do I automatically route when in Flutter from within main()?

使用Get.context在從 controller 導航時對我有用,例如: GoRouter.of(Get.context.);go('/search');

只是檢查錯誤的潛在原因 - 您的main.dart文件是什么樣的?

您使用的是MaterialApp.router(...)還是GetMaterialApp(...)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM