我想要一个底部的导航栏,但是“选项卡”应该是纯文本的。问题在于,该图标是BottomNavigationBarItem()的必需属性。
编辑:我使用选项卡栏作为底部导航栏来工作,但是@Fernando Rocha的解决方案似乎不那么棘手,效果更好。总结起来,只需在每个图标上添加“ size:0”(您仍然需要一个图标)。
答案 0 :(得分:2)
我在图标尺寸上使用了0号,并且有效
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
/// This Widget is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: MyStatefulWidget(),
);
}
}
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
int _selectedIndex = 0;
static const TextStyle optionStyle =
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
static const List<Widget> _widgetOptions = <Widget>[
Text(
'Index 0: Home',
style: optionStyle,
),
Text(
'Index 1: Business',
style: optionStyle,
),
Text(
'Index 2: School',
style: optionStyle,
),
];
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('BottomNavigationBar Sample'),
),
body: Center(
child: _widgetOptions.elementAt(_selectedIndex),
),
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home, size: 0),
title: Text('Home'),
),
BottomNavigationBarItem(
icon: Icon(Icons.business, size: 0),
title: Text('Business'),
),
BottomNavigationBarItem(
icon: Icon(Icons.school, size: 0),
title: Text('School'),
),
],
currentIndex: _selectedIndex,
selectedItemColor: Colors.amber[800],
onTap: _onItemTapped,
),
);
}
}
答案 1 :(得分:1)
您可以
<ItemTemplate>
<a href="<%# Page.ResolveUrl(string.Format("~/BusinessHandlers/FileDownLoad.ashx?FileName={0}", Eval("FileName"))) %>">My text</a>
</ItemTemplate>
实现这一目标。
使用这种方法时,“应”放置图标的地方仍将有一个空白空间。使用@Fernando Rocha的方法,看起来文本居中。