! use provider to save the context
let NavBar is the widget out of the indexedStack
-create NavBarVM and let it be a provider
-create a variable "navBarContext" in NavBarVM
-create the function "setNavBarContext" & "getNavBarContext"
-when navbar build:
build(BuildContext context) {
setNavBarContext(context);
}
something like that
-in the indexedStack widget
BuildContext navBarContext = context.read<NavbarVM>().getNavBarContext();
Navigator.push(
navBarContext,
MaterialPageRoute(
builder: (navBarContext) =>
SecondPage()
),
);
沒有留言:
發佈留言