Flutter获取当前路由路径 旺仔小小馒头 2021-08-03 5,672 阅读1分钟 Flutter提供的方式 需要传入BuildContext var routePath = ModalRoute.of(context).settings.name; print("current route: $name") GetX提供的方式 可以直接使用以下方式,而不必传入BuildContext. var routePath = Get.currentRoute; print("current route: $name"); 必须确保注册了路由,否则无法使获取到