Flutter 颤振选项卡栏高度图标 导入“包装:颤振/材料.省道”; 类TestTab扩展了无状态小部件{ 最终列表myTabs=[ 标签( 子:Image.asset( “资产/图标/项目/项目001.png”, ), ), ... 标签( 图标:Image.asset( “assets/icons/project/all.png”, 身高:100, ), ), ... 标签( 图标:Image.asset( “资产/图标/项目/proj_009.png”, ), ), ]; @凌驾 小部件构建(构建上下文){ 返回DefaultTabController( 初始索引:5, 长度:myTabs.length, 孩子:脚手架( appBar:首选大小( 首选尺寸:从高度开始的尺寸(150.0), 孩子:AppBar( 底部:选项卡栏( isScrollable:是的, 标签:我的标签, ), ), ), 正文:选项卡视图( 子项:myTabs.map((选项卡){ 返回中心( 子:文本( "测试",, 样式:常量文本样式(字体大小:36), ), ); }).toList(), ), ), ); } }
我试图增加图标的高度,但没有效果。就好像他自己选择了所有的参数。不允许减小图元的宽度或增加图元的高度Flutter 颤振选项卡栏高度图标 导入“包装:颤振/材料.省道”; 类TestTab扩展了无状态小部件{ 最终列表myTabs=[ 标签( 子:Image.asset( “资产/图标/项目/项目001.png”, ), ), ... 标签( 图标:Image.asset( “assets/icons/project/all.png”, 身高:100, ), ), ... 标签( 图标:Image.asset( “资产/图标/项目/proj_009.png”, ), ), ]; @凌驾 小部件构建(构建上下文){ 返回DefaultTabController( 初始索引:5, 长度:myTabs.length, 孩子:脚手架( appBar:首选大小( 首选尺寸:从高度开始的尺寸(150.0), 孩子:AppBar( 底部:选项卡栏( isScrollable:是的, 标签:我的标签, ), ), ), 正文:选项卡视图( 子项:myTabs.map((选项卡){ 返回中心( 子:文本( "测试",, 样式:常量文本样式(字体大小:36), ), ); }).toList(), ), ), ); } },flutter,height,tabbar,Flutter,Height,Tabbar,我试图增加图标的高度,但没有效果。就好像他自己选择了所有的参数。不允许减小图元的宽度或增加图元的高度 请告诉我如何增加元素的高度?您必须为自定义制作自定义选项卡栏。像这样的 自定义选项卡栏 import 'package:flutter/material.dart'; class TestTab extends StatelessWidget { final List<Tab> myTabs = <Tab>[ Tab( child: Image.a
请告诉我如何增加元素的高度?您必须为自定义制作自定义选项卡栏。像这样的 自定义选项卡栏
import 'package:flutter/material.dart';
class TestTab extends StatelessWidget {
final List<Tab> myTabs = <Tab>[
Tab(
child: Image.asset(
'assets/icons/project/proj_001.png',
),
),
...
Tab(
icon: Image.asset(
'assets/icons/project/all.png',
height: 100,
),
),
...
Tab(
icon: Image.asset(
'assets/icons/project/proj_009.png',
),
),
];
@override
Widget build(BuildContext context) {
return DefaultTabController(
initialIndex: 5,
length: myTabs.length,
child: Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(150.0),
child: AppBar(
bottom: TabBar(
isScrollable: true,
tabs: myTabs,
),
),
),
body: TabBarView(
children: myTabs.map((Tab tab) {
return Center(
child: Text(
'Test',
style: const TextStyle(fontSize: 36),
),
);
}).toList(),
),
),
);
}
}
如果你想设置图标的大小小,那么你可以这样做
import 'package:flutter/material.dart';
import 'change_text_size_tabbar_task-3.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
//home: MyHomePage(title: 'Flutter Demo Home Page'),
home: ChangeTextSizeTabbar(),
);
}
}
这里的
大小:15,
将使图标大小符合您的要求抱歉,但我在您的示例中没有看到自定义:(哦,我的糟糕,我错过了!对不起。但我看不到您的代码与我的代码有任何差异。尽管如此。请指定允许您启用自定义的特定位置。
import 'package:flutter/material.dart';
import 'change_text_size_tabbar_task-3.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
//home: MyHomePage(title: 'Flutter Demo Home Page'),
home: ChangeTextSizeTabbar(),
);
}
}
Tab(
text: "Category List",
icon: Icon(Icons.home,size: 15,),
),
Tab(
text: "Product List",
icon: Icon(Icons.view_list,size: 15,),
),
Tab(
text: "Contact Us",
icon: Icon(Icons.contacts,size: 15,),
),
Tab(
text: "Darshan Timing",
icon: Icon(Icons.access_time,size: 15,),
)