使用IndexedStack

class _TabsState extends State<Tabs> {
  int _currentIndex = 0;

  List<Widget> _tabBody = [
    MyList(),
    Category(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("One Vision影视"),
      ),
      body: IndexedStack(
        index: this._currentIndex,
        children: this._tabBody,
      ),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: this._currentIndex,
        onTap: (index) {
          setState(() {
            this._currentIndex = index;
          });
        },
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), title: Text("主页")),
          BottomNavigationBarItem(icon: Icon(Icons.category), title: Text("分类")),
        ],
      ),
    );
  }
}
说点什么
禁止广告!
好耶,沙发还空着ヾ(≧▽≦*)o
Loading...