Wei*_*ong 5 tabs flutter flutter-appbar
我一直在尝试很多用选项卡更改应用栏标题的解决方案,我解决了它,但现在有一个小问题;当按下选项卡时,应用栏确实会随着选项卡而变化,但选项卡栏视图不会。在选项卡栏视图上向左或向右滑动会更改选项卡栏视图,但不会更改选项卡(应用程序栏标题也不会更改)。
我的代码如下:
final List<Tabs> _tabs = [new Tabs(title: "Registered UAS", icon: new IconData(58826, fontFamily: 'MaterialIcons')),
new Tabs(title: "Registration", icon: IconData(57680, fontFamily: 'MaterialIcons'))
];
Tabs _myHandler ;
void initState() {
super.initState();
_controller = new TabController(length: 2, vsync: this);
_myHandler = _tabs[0];
_controller.addListener(_handleSelected);
}
void _handleSelected() {
setState(() {
_myHandler= _tabs[_controller.index];
});
}
@override
Widget build(BuildContext context) {
return WillPopScope(
child: DefaultTabController(
length: 2,
child: new Scaffold(
appBar: AppBar(
title: Text(_myHandler.title),
bottom: new TabBar(
controller: _controller,
tabs: <Widget>[
new Tab(icon: new Icon(_tabs[0].icon)),
new Tab(icon: new Icon(_tabs[1].icon))
],
),
),
body: new TabBarView(children: [...])
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3337 次 |
| 最近记录: |