Flutter 从不同页面更新内部页面存储
我在主页中使用底部导航栏,我有3个不同的页面。 我的屏幕Flutter 从不同页面更新内部页面存储,flutter,Flutter,我在主页中使用底部导航栏,我有3个不同的页面。 我的屏幕 final List<Widget> screens = [ findLocation(), otherPage(), profilePage(), ]; 像这样查找位置页 return Scaffold( body: PageStorage( child: currentScreen, bucket: bucket, ),
final List<Widget> screens = [
findLocation(),
otherPage(),
profilePage(),
];
像这样查找位置页
return Scaffold(
body: PageStorage(
child: currentScreen,
bucket: bucket,
),
floatingActionButton: showFab?GestureDetector(
onTap: () {
setState(() {
currentScreen =
findLocation(); // if user taps on this location tab will be active
currentTab = 0;
});
},
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Color(0xFF0B75E0), // background
onPrimary: Colors.white,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(
right: 25.0, left: 15, top: 12, bottom: 10),
child: Text(
'Konum Bul',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(255, 255, 255, 1),
fontSize: 23,
letterSpacing: 1.5,
fontWeight: FontWeight.w500,
height: 1),
),
),
Icon(
Icons.arrow_forward,
color: Colors.white,
)
],
),
onPressed: () {
Navigator.push(context,
new MaterialPageRoute(builder: (context) => new loginPage()));
},
),
当我在“查找位置”页面打开时单击该页面上的按钮时,我希望打开的页面与main中的3个页面不同(我有第4个登录页面),但我的新登录页面打开的位置不同(没有bottomnavigatorbar)
我想像其他人一样在主页上打开这个页面。我希望它是下面的塔巴。如何做到这一点。如果您询问为什么bottomnavigatorbar没有显示在登录页面中,答案将是: 因为您在onPressed中执行此代码:
Navigator.push(context,new MaterialPageRoute(builder: (context) => new loginPage()));
这个代码将打开一个新的路由
尝试在onPressed中编写此代码:
setState((){
currentScreen = loginPage();
});
问题是我的currentScreen变量位于主页面中。我无法从“位置”页面更改它。在浏览主页上现有的3个页面时,我已经通过设置currentScreen=1、currentScreen=2进行了浏览。您可以共享此页面的完整代码吗。我想看看变量和其他东西的数据类型