2

我已经使用了背景导航,现在我无法在此代码中添加底部导航栏,请我是新来的颤振,任何人都可以帮助我。

这是我的gridview,它作为我的背景导航栏的frontlayer。

var myGridView = new GridView.builder(
  itemCount: spacecrafts.length,
  gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
    crossAxisCount: 3,
    // childAspectRatio: (itemWidth / itemHeight),
  ),
  itemBuilder: (BuildContext context, int index) {
    return new GestureDetector(
      child: new Card(
        elevation: 5.0,
        child: new Container(
          alignment: Alignment.centerLeft,
          child: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                Image.asset(
                  images[index],
                  color: Colors.blue,
                ),
                Text(
                  spacecrafts[index],
                  style: TextStyle(color: Colors.blue),
                )
              ],
            ),
          ),
        ),
      ),
    );
  },
);

int _currentIndex = 0;
final List<Widget> _pages = [
  Profile(),
  AboutUs(),
  TermsAndConditions(),
  SignOut()
];

这是我的背景导航条码

return new BackdropScaffold(
  appBar: new BackdropAppBar(
    title: new Text("Flutter GridView"),
  ),
  stickyFrontLayer: true,
  frontLayer: myGridView,
  backLayer: BackdropNavigationBackLayer(
    items: [
      ListTile(leading: Image.asset("images/user.png", color: Colors.white),
          title: Text("YOUR PROFILE",
            style: TextStyle(color: Colors.white),)),
      ListTile(leading: Image.asset("images/logout.png",
          color: Colors.white), title: Text("LOGOUT",
          style: TextStyle(color: Colors.white))),
    ],
    onTap: (int position) => {setState(() => _currentIndex = position)},
  ),
);

}

4

1 回答 1

0

Flutter Scaffolds 有一个内置的底部导航栏,您可以像使用 appbar & body 一样使用它。这里有一个例子。

Scaffold(

appbar: Appbar( 


)

body: Container()



 bottomNavigationBar: BottomNavigationBar(items: <BottomNavigationBarItem>[
        BottomNavigationBarItem(
          icon: Icon(Icons.home),
          title: Text('FooBar'),
          
        )

)
于 2020-06-24T16:41:05.243 回答