Unity_UIWidgets学习笔记09_组件BottomNavigationBar

参考地址 https://api.flutter.dev/flutter/material/BottomNavigationBar-class.html

1、

 public BottomNavigationBar(
            Key key = null,
            List<BottomNavigationBarItem> items = null,//所有子项目
            ValueChanged<int> onTap = null,//点击
            int currentIndex = 0,//当前选择索引
            BottomNavigationBarType? type = null,//不清楚有
            Color fixedColor = null,
            float iconSize = 24.0f//图标大小
        )
public BottomNavigationBarItem(
            Widget icon = null,//图标
            Widget title = null,//变态
            Widget activeIcon = null,//激活图标
            Color backgroundColor = null//背景色
        )

2、例子

int selectedIndex = 0;
    TextStyle optionStyle = new TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
    List<Widget> widgetOptions
    {
        get
        {
            return new List<Widget>{
            new Text(
                "Index 0: Home",
                style: optionStyle
            ),
            new Text(
                "Index 1: Business",
                style: optionStyle
            ),
            new  Text(
                "Index 2: School",
                style: optionStyle
            ),
        };

        }
    }
    void onItemTapped(int index)
    {
        setState(() =>
        {
            selectedIndex = index;
        });
    }
public override Widget build(BuildContext context)
    {
        return new Scaffold(
          appBar: new AppBar(
          title: new Text("BottomNavigationBar Sample")
          ),
          body: new Center(
          child: widgetOptions[selectedIndex]
          ),
          bottomNavigationBar: new BottomNavigationBar(
          items: new List<BottomNavigationBarItem>(){
               new  BottomNavigationBarItem(
                icon: new Icon(Icons.home),
                title:new  Text("Home")
                ),
               new  BottomNavigationBarItem(
                icon: new Icon(Icons.business),
                title:new  Text("Business")
                ),
               new  BottomNavigationBarItem(
                icon: new Icon(Icons.school),
                title: new Text("School")
                ),
          },
          currentIndex: selectedIndex,
          onTap: onItemTapped
          )
      );

    }

 

转载于:https://www.cnblogs.com/PandaHome/p/11114131.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值