【发布时间】:2020-04-01 15:49:41
【问题描述】:
我是flutter的新手,我正在尝试实现类似whatsApp的界面,在appBar的whatsapp右上角有垂直的3个点,显示不同选项列表根据所选标签。我想要类似的东西。尝试寻找 appBar 的构造函数,但无法找到解决方案如何开始。先感谢您。只需要提示即可开始。
【问题讨论】:
标签: flutter
我是flutter的新手,我正在尝试实现类似whatsApp的界面,在appBar的whatsapp右上角有垂直的3个点,显示不同选项列表根据所选标签。我想要类似的东西。尝试寻找 appBar 的构造函数,但无法找到解决方案如何开始。先感谢您。只需要提示即可开始。
【问题讨论】:
标签: flutter
import 'package:flutter/material.dart';
class Example extends StatefulWidget {
static const routeName = 'example';
@override
_ExampleState createState() => _ExampleState();
}
class _ExampleState extends State<Example> with SingleTickerProviderStateMixin {
void _getCurrentTab() {
if (_tabController.index == 0) {
//execute code for first tab
} else if (_tabController.index == 1) {
//execute code for second tab
} else {
//execute code for third tab
}
}
TabController _tabController;
final List<Tab> tabs = [
Tab(
child: Icon(
Icons.motorcycle,
),
),
Tab(
child: Icon(
Icons.local_airport,
),
),
Tab(
child: Icon(
Icons.local_taxi,
),
),
];
@override
void initState() {
super.initState();
_tabController = new TabController(vsync: this, length: tabs.length);
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 3,
initialIndex: 0,
child: Scaffold(
appBar: AppBar(
title: Text('Title Goes Here'),
centerTitle: true,
actions: <Widget>[
IconButton(
icon: Icon(Icons.more_horiz),
onPressed: () => _getCurrentTab(),
)
],
bottom: TabBar(
controller: _tabController,
tabs: tabs,
),
),
),
);
}
}
【讨论】: