【发布时间】:2022-01-24 06:00:58
【问题描述】:
我的项目中有一个路由器类,我想在其中使用路由器中的地址。我知道我应该使用导航器。 push(context, my router) 但我想在没有 onpressed 或 onTap 的情况下使用它。我想返回小部件。 这是我的班级路由器:
Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/firstPage': (context) => const FirstPage(),
'/': (context) => const BottomNavBar( activeTabIndex: 0),
'/exploreHome/podcastsProfile': (context) =>PodcastsProfile(podId: exploreManager.podId),
'/exploreHome/morepagepod': (context) =>MorePod(moreId: exploreManager.moreId,showProfilePodcasts: exploreManager.showProfilePodcasts),
'/exploreHome/morepageepd': (context) =>MoreEpd(moreId: exploreManager.moreId ),
};
我想使用路由器类而不是直接调用我的类:
使用'/exploreHome/podcastsProfile' 而不是PodcastsProfile(podId: podId);
Widget renderBody(String page) {
Widget widget = Container();
switch (page) {
case podcastsProfile:
widget = **PodcastsProfile(
podId: podId,
);**
}
return Container();
}
【问题讨论】:
标签: flutter dart widget router navigator