Flutter

【Flutter】导航控件

2019-03-21  本文已影响0人  diva_dance

AppBar

image
  appBar: AppBar(
      title: Text('title'), // 标题
      actions: [
        Icon(Icons.share)
      ], // 用来展示右侧的组件
      elevation: 20, // z 轴阴影
      backgroundColor: Colors.red, // 背景色
      centerTitle: false,
      titleSpacing: 10,
      toolbarOpacity: .5,
      bottomOpacity: .5,
      leading: Icon(Icons.star), // 用来显示一个按钮去关闭当前页面或者打开一个 drawer
      flexibleSpace: FlexibleSpaceBar(
        title: Text('flexibleSpace'),
      ),
      bottom: PreferredSize(
          child: Container(
            color: Colors.red,
            child: Text('bottom'),
          ),
          preferredSize: Size(500.0, 100.0)
      ),
      automaticallyImplyLeading: true,
    )

BottomNavigation

  bottomNavigationBar: BottomNavigationBar(
      iconSize: 20.0,
      type: BottomNavigationBarType.fixed,
      fixedColor: Colors.blue,
      onTap: (index) {
        _currentIndex = index;
        print(index);
      },
      currentIndex: _currentIndex,
      items: <BottomNavigationBarItem> [
        BottomNavigationBarItem(
          icon: Icon(Icons.star),
          title: Text('星星-1'),
          activeIcon: Icon(
            Icons.star,
            color: Colors.red,
          )
        ),
        BottomNavigationBarItem(
          icon: Icon(Icons.nature),
          title: Text('星星-2')
        ),
        BottomNavigationBarItem(
            icon: Icon(Icons.menu),
            title: Text('星星-3')
        ),
      ],
    )
image

Drawer

主要是通过 child 设置列表

    drawer: Drawer(
      child: Text('Drawer')
    ),

通过代码控制抽屉打开

  leading: Builder(
        builder: (context) => IconButton(
          icon: new Icon(Icons.settings),
          onPressed: () => Scaffold.of(context).openDrawer(),
        ),
      ),

Scaffold

上一篇下一篇

猜你喜欢

热点阅读