flutter - Flutter ConvexAppBar 如何改变文字样式?
问题描述
当我尝试更改 TextStyle 时,它显示“无法将参数类型‘文本’分配给参数类型‘字符串’。” 我怎样才能改变它?
- 我正在使用convex_bottom_bar 3.0.0
- 如果我弄错了,对不起我的英语
bottomNavigationBar: ConvexAppBar(
items: [
TabItem(icon: Icons.touch_app_rounded, title: Text("Tab1",style: TextStyle(fontFamily: "iransans"),)),
TabItem(icon: Icons.store_rounded, title: 'Mağaza'),
TabItem(icon: Icons.developer_board_rounded, title: 'Simülasyon'),
TabItem(icon: Icons.timeline_rounded, title: 'İstatistik'),
TabItem(icon: Icons.view_week_rounded, title: 'Diğer'),
],
gradient: LinearGradient(
colors: [Color(0xFFEC407A),
Color(0XFF1A237E)],
begin: Alignment.bottomCenter,
stops: [
0.0,0.4
],
end: Alignment.topCenter,
),
height: 70,
backgroundColor: Color(0xFFEC407A),
//backgroundColor: Colors.white,
activeColor: Colors.white,
initialActiveIndex: 0,//optional, default as 0
onTap: (int i) => print('click index=$i'),
),
解决方案
//Don't use Text () and use the StyleProvider Widget in your bottomNavigationBar. In
//TextStyle add fontFamily.
bottomNavigationBar: StyleProvider(
style: Style(),
child: ConvexAppBar(
initialActiveIndex: 1,
height: 50,
top: -30,
curveSize: 100,
style: TabStyle.fixedCircle,
items: [
TabItem(icon: Icons.link),
TabItem(icon: Icons.import_contacts),
TabItem(title: "2020", icon: Icons.work),
],
backgroundColor: _tabBackgroundColor,
),
)
class Style extends StyleHook {
@override
double get activeIconSize => 40;
@override
double get activeIconMargin => 10;
@override
double get iconSize => 20;
@override
TextStyle textStyle(Color color) {
return TextStyle(fontSize: 20, color: color);
}
}
推荐阅读
- mysql - ORA-00904: Oracle SQL 中的标识符无效
- javascript - Javascript图表未加载
- javascript - 显示存储在数组中的事件
- c++ - 为什么对模板化函数有模棱两可的调用?
- reactjs - CKEditor 更新 React 状态
- java - 服务器端渲染 Spring 和 Vue.js
- javascript - Nuxt vuex状态菜单列表:组件中未定义
- javascript - Escape 按键不适用于 vuejs 中的第二个模态窗口
- laravel - 如果两个外键匹配,如何在多对多关系中找到速率?
- r - 通过闪亮的应用程序运行 bat 文件时的进度条