如何通过底部导航栏将数据获取到用户可以访问的屏幕?

问题描述

用户从另一个屏幕转到显示底部导航栏的屏幕。目标是将数据从用户所在的第一个屏幕传递到用户可以通过底部导航栏进入的两个屏幕之一。我已经尝试了一个代码,但是没有用...我已经可以将数据从第一个屏幕传递到底部的导航栏文件,但是我不知道如何将数据传递到一个“底部”的文件导航栏屏幕”。我用myReservations(userUID: widget.userUID,)尝试过,数据应该传递到myReservations

我尝试了以下代码:

class bottomNavBar extends StatefulWidget {
  var userUID;

  bottomNavBar({Key key,this.userUID}) : super(key: key);
  @override
  _bottomNavBarState createState() => _bottomNavBarState();
}

class _bottomNavBarState extends State<bottomNavBar> {
  int _currentIndex = 0;
  final List<Widget> _children = [
    maps4(),myReservations(
      userUID: widget.userUID,),];

  void onTappedBar(int index) {
    setState(() {
      _currentIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Bottom Navigation Bar'),body: _children[_currentIndex],bottomNavigationBar: BottomNavigationBar(
        onTap: onTappedBar,currentIndex: _currentIndex,items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.map),title: Text('Map'),BottomNavigationBarItem(
            icon: Icon(Icons.ac_unit),title: Text('My Reservations'),],);
  }
}

这是myReservations文件中的代码(此代码已在另一个项目中工作):

 var userUID;
 myReservations({Key key,this.userUID}) : super(key: key);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)