如何添加 4 个孩子或在某些情况下将 3 或 2 添加到颤振中的列。
Column(
children: <Widget>[_weatherData],
)
Run Code Online (Sandbox Code Playgroud) 我正在使用 Flutter 默认选项卡控制器来显示选项卡视图。我需要在单击按钮时更改选项卡,我尝试使用 setState 更改选项卡,但失败了。这些是我的代码:
class _TabPageState extends State<TabPage> implements TabView {
int tabIndex = 0;
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 4,
initialIndex: tabIndex,
child: Scaffold(
appBar: AppBar(),
body: TabBarView(
physics: NeverScrollableScrollPhysics(),
children: [
Container(
color: Colors.green,
child: Center(
child: RaisedButton(
child: Text('to Tab 3'),
onPressed: () {
setState(() {
tabIndex = 2;
});
}),
),
),
Container(color: Colors.red),
Container(color: Colors.yellow),
Container(color: Colors.cyan),
],
),
bottomNavigationBar: TabBar(
labelColor: Colors.black45,
tabs: [
Padding(padding: const EdgeInsets.only(top: 12, bottom: 12), …Run Code Online (Sandbox Code Playgroud)