Flutter BottomNavigationBarItem


简介

BottomNavigationBarItem “底部导航应用栏”

  • material 的 BottomNavigationBar 或带有图标和标题的 iOS主题 CupertinoTabBar 中的交互式按钮;

基本用法

这个类很少单独使用。通常嵌入在上面的一个底部 bottom navigation widgets 中;

实例演示

import 'package:flutter/material.dart';

/*
* BottomNavigationBarItem 默认的实例,无状态
* */
class BottomNavigationBarItemLessDefault extends StatelessWidget {
  final widget;
  final parent;

  const BottomNavigationBarItemLessDefault([this.widget, this.parent])
      : super();

  @override
  Widget build(BuildContext context) {
    return  SizedBox(
        height: 100,
        child: Scaffold(
          bottomNavigationBar:  BottomNavigationBar(items: [
             BottomNavigationBarItem(
                icon:  Icon(Icons.laptop_chromebook),
                title:  Text("主页"),
                backgroundColor: Colors.red
            ),
             BottomNavigationBarItem(
                icon:  Icon(Icons.list), title:  Text("分类"),backgroundColor: Colors.grey),
             BottomNavigationBarItem(
                icon:  Icon(Icons.local_grocery_store), title:  Text("购物车")),
             BottomNavigationBarItem(icon:  Icon(Icons.person), title:  Text("我的"))
          ],
            //onTap: onTap,
            //currentIndex: page
          ),
        )
    );
  }
}

//backgroundColor: Colors.grey,
//
////      body:  PageView(
////
////          children: [
////             Index(),
////             Classify(),
////             Shopping(),
////             Myself()
////          ],
////
////          controller: pageController,
////          onPageChanged: onPageChanged
////      ),
//