Flutter 颤振底部导航栏中的点击文本大尺寸控制
我正在使用颤振的底部导航栏。点击导航栏图标时,文本变大。但它对我来说有点大,如下图所示。Flutter 颤振底部导航栏中的点击文本大尺寸控制,flutter,Flutter,我正在使用颤振的底部导航栏。点击导航栏图标时,文本变大。但它对我来说有点大,如下图所示。 我想控制点击文本的大尺寸,并使其小一点。我怎样才能在弗利特做到这一点 代码如下: import 'package:flutter/material.dart'; import 'package:adminify/pages/PageOne.dart'; import 'package:adminify/pages/PageTwo.dart'; import 'package:adminify/pages/
我想控制点击文本的大尺寸,并使其小一点。我怎样才能在弗利特做到这一点 代码如下:
import 'package:flutter/material.dart';
import 'package:adminify/pages/PageOne.dart';
import 'package:adminify/pages/PageTwo.dart';
import 'package:adminify/pages/PageThree.dart';
import 'package:adminify/pages/PageFour.dart';
import 'package:adminify/pages/PageFive.dart';
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
int _currentIndex = 0;
@override
void initState() {
super.initState();
}
void navigationTapped(int page) {
setState(() {
_currentIndex = page;
});
}
@override
Widget build(BuildContext context) {
// this is all pages here in list we can choose index when click bottom navigation bar
List<Widget> _allPages = [
PageOne(),
PageTwo(),
PageTree(),
PageFour(),
PageFive(),
];
return Scaffold(
body: _allPages[_currentIndex],
bottomNavigationBar: buildBottomNavigationBar(),
);
}
// Bottom navigation bar area you can choose icons what you want.
BottomNavigationBar buildBottomNavigationBar() {
return BottomNavigationBar(
type: BottomNavigationBarType.fixed,
fixedColor: Colors.red,
currentIndex: _currentIndex,
onTap: navigationTapped,
// iconSize: 28,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text(
"Home",
style: TextStyle(fontWeight: FontWeight.normal),
),
),
BottomNavigationBarItem(
icon: Icon(
Icons.explore,
),
title: Text(
"Admission",
style: TextStyle(fontWeight: FontWeight.normal),
),
),
BottomNavigationBarItem(
icon: Icon(Icons.cloud),
title: Text(
"University",
style: TextStyle(fontWeight: FontWeight.normal),
overflow: TextOverflow.clip,
textAlign: TextAlign.center,
),
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
title: Text(
"Favorites",
style: TextStyle(fontWeight: FontWeight.normal),
),
),
BottomNavigationBarItem(
icon: Icon(Icons.verified_user),
title: Text(
"Profile",
style: TextStyle(fontWeight: FontWeight.normal),
),
),
],
);
}
}
导入“包装:颤振/材料.省道”;
导入“package:adminify/pages/PageOne.dart”;
导入“package:adminify/pages/PageTwo.dart”;
导入“package:adminify/pages/PageThree.dart”;
导入“package:adminify/pages/PageFour.dart”;
导入“package:adminify/pages/PageFive.dart”;
类主屏幕扩展StatefulWidget{
@凌驾
_HomeScreenState createState()=>\u HomeScreenState();
}
类_homescrenstate使用TickerProviderStateMixin扩展状态{
int _currentIndex=0;
@凌驾
void initState(){
super.initState();
}
无效导航点击(整版){
设置状态(){
_currentIndex=页面;
});
}
@凌驾
小部件构建(构建上下文){
//这是列表中的所有页面,我们可以在单击底部导航栏时选择索引
列表_所有页面=[
第一页(),
第二页(),
PageTree(),
第四页(),
第五页(),
];
返回脚手架(
正文:_allPages[_currentIndex],
bottomNavigationBar:buildBottomNavigationBar(),
);
}
//底部导航栏区域,您可以选择您想要的图标。
BottomNavigationBar构建BottomNavigationBar(){
返回底部导航栏(
类型:BottomNavigationBarType.fixed,
固定颜色:颜色。红色,
currentIndex:_currentIndex,
onTap:navigationTapped,
//iconSize:28,
项目:[
底部导航气压计(
图标:图标(Icons.home),
标题:正文(
“家”,
样式:文本样式(fontWeight:fontWeight.normal),
),
),
底部导航气压计(
图标:图标(
图标。探索,
),
标题:正文(
“接纳”,
样式:文本样式(fontWeight:fontWeight.normal),
),
),
底部导航气压计(
图标:图标(Icons.cloud),
标题:正文(
“大学”,
样式:文本样式(fontWeight:fontWeight.normal),
溢出:TextOverflow.clip,
textAlign:textAlign.center,
),
),
底部导航气压计(
图标:图标(Icons.person),
标题:正文(
“收藏夹”,
样式:文本样式(fontWeight:fontWeight.normal),
),
),
底部导航气压计(
图标:图标(图标。已验证用户),
标题:正文(
“个人资料”,
样式:文本样式(fontWeight:fontWeight.normal),
),
),
],
);
}
}
如果您检查底部导航栏的源代码。dart
,您将看到底部导航栏的活动字体大小是固定的,如下所示:
const double _kActiveFontSize = 14.0;
如果您想更改此设置,我认为您需要创建自己的自定义底部导航栏,使其达到所需的活动字体大小。通过查看底部导航栏代码,您不能。它似乎使用了设置为
14
的硬编码\u kActiveFontSize
。检查底部导航栏。对于固定标签
样式,请选择省道
第366行;对于移动标签
样式,请选择第411行。您可能需要创建一个问题来修复该问题在底部导航栏上有一个属性selectedFontSize
。
你可以用这个。只需将大小(整数)设置为所需的值
额外的;底部导航栏上还有一个未选择的fontsize,您可以将所有标题fontsize设置为所需大小
bottomNavigationBar: BottomNavigationBar(
currentIndex: index,
onTap: (int index) {
setState(() {
this.index = index;
});
},
backgroundColor: Colors.white,
type: BottomNavigationBarType.fixed,
selectedFontSize: 12,
unselectedFontSize: 12,
items: [
BottomNavigationBarItem(
icon: ClipOval(
child: Container(
color:
omitted ...