Flutter:底部导航栏组件-BottomNavigationBar
简介底部导航条BottomNavigationBar,可以非常方便的实现tap之间的切换。
底部导航条BottomNavigationBar,可以非常方便的实现tap之间的切换。
BottomNavigationBar主要属性:
- currentIndex:int类型,当前索引
- fixedColor:Color类型,选中按钮的颜色
- iconSize:double类型,按钮图标的大小
- items:List
类型,底部导航按钮集 - onTap:ValueChanged
,按下某个按钮的回调事件
底部导航栏Demo
import 'package:flutter/material.dart';
class BottomNavigationBarWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
int _selectIndex = 1;
return Scaffold(
appBar: AppBar(
title: Text('风格组件:BottomNavigationBar'),
centerTitle: true,
elevation: 0.0,
),
body: null,
bottomNavigationBar: BottomNavigationBar(
onTap: (index) {
print(index);
},
currentIndex: _selectIndex, //设置当前索引
type: BottomNavigationBarType.fixed, //超过3个item时就需要设置该选项,否则不会显示
items: [
BottomNavigationBarItem(
//设置文字
label: '信息',
//设置图标
icon: Icon(Icons.message),
),
BottomNavigationBarItem(
label: '朋友',
icon: Icon(Icons.contact_phone),
),
BottomNavigationBarItem(
label: '消息',
icon: Icon(Icons.message),
),
BottomNavigationBarItem(
label: '我的',
icon: Icon(Icons.account_circle),
),
],
),
);
}
}
如果需要进行切换,就需要将组件设置成StatefulWidget,然后将如下代码
onTap: (index) {
print(index);
},
改成:
setState(() {
_selectIndex = index;
});
打包出现如下错误:Error: Application entry file "dist\electron\main.js" in the "D:\gui\demo2\build\win-unpacked\resources\app.asar" does not exist. Seems like a wrong configuration.
在Mac电脑中,如何对Git的用户名和密码进行修改呢?起初不懂Mac,所以整了很久,本文将记录如何对这个进行操作,以便后期使用。
《康熙王朝》是一部非常优秀的电视连续剧,陈道明演的康熙是我觉得最有帝王气魄,让人意犹未尽,本文主要记录一小段非常经典的对白。
为了能让虚拟机能连接网络,并且能与宿主机能相互进行访问,所以需要多虚拟机几种网络模式进行学习,以便后期能快速的进行配置。
单一职责原则(Single Responsibility Principle,SRP)又称单一功能原则,由罗伯特·C.马丁(Robert C. Martin)于《敏捷软件开发:原则、模式和实践》一书中提出的。这里的职责是指类变化的原因,单一职责原则规定一个类应该有且仅有一个引起它变化的原因,否则类应该被拆分(There should never be more than one reason for a class to change)。
快速生成表格
在使用Git的过程中,不想每次都输入用户名和密码去拉取代码,所以就需要保存这些信息,那么既然有保存了,就必须有清除功能。
Docker编译镜像出现:fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.12/main: temporary error (try again later)
WARNING: Ignoring APKINDEX.2c4ac24e.tar.gz: No such file or directory问题