我如何在 Flutter 中与其他组件一起在页面中实现选项卡控制器?
How can i implement tab controller in a page with other component in Flutter?
我想在我的 flutter 应用程序的页面中添加一个选项卡控制器和其他组件。
我怎样才能做到这一点?
当我添加 TabBar 时它没问题,但是当我添加 TabBarView 时它就不起作用了。
我附上了页面的屏幕截图。我想做这个。我怎样才能在 flutter 应用程序中做到这一点?
class Details extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Center(
child: new Column(
children: <Widget>[
new DropdownButton<String>(
items: <String>['USD', 'EUR', 'LTC'].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (_) {},
value: 'USD',
),
new Text(
'$6,146.76',
style: new TextStyle(
fontWeight: FontWeight.bold,
fontSize: 40.0,
color: Theme.of(context).accentColor,
),
),
new Text('Last Updated at'),
new DefaultTabController(
length: 2,
child: new Container(
child: new Column(
children: <Widget>[
new TabBar(
labelColor: Theme.of(context).accentColor,
tabs: [
new Tab(text: 'General'),
new Tab(text: 'Mining'),
]
),
new TabBarView(
children: [
new Tab(child: new General()),
new Tab(child: new Mining()),
],
),
],
),
)
)
],
),
),
);
}
}
Text("Controls above tabs"),
DefaultTabController(
length: 2,
child: SizedBox(
height: 100.0,
child: Column(
children: <Widget>[
TabBar(
tabs: <Widget>[
Tab(
text: "tab1",
),
Tab(
text: "tab2",
)
],
),
Expanded(
child: TabBarView(
children: <Widget>[
Container(
color: Colors.green,
),
Container(
color: Colors.yellow,
),
],
),
),
],
),
),
),
我想在我的 flutter 应用程序的页面中添加一个选项卡控制器和其他组件。 我怎样才能做到这一点? 当我添加 TabBar 时它没问题,但是当我添加 TabBarView 时它就不起作用了。 我附上了页面的屏幕截图。我想做这个。我怎样才能在 flutter 应用程序中做到这一点?
class Details extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Center(
child: new Column(
children: <Widget>[
new DropdownButton<String>(
items: <String>['USD', 'EUR', 'LTC'].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (_) {},
value: 'USD',
),
new Text(
'$6,146.76',
style: new TextStyle(
fontWeight: FontWeight.bold,
fontSize: 40.0,
color: Theme.of(context).accentColor,
),
),
new Text('Last Updated at'),
new DefaultTabController(
length: 2,
child: new Container(
child: new Column(
children: <Widget>[
new TabBar(
labelColor: Theme.of(context).accentColor,
tabs: [
new Tab(text: 'General'),
new Tab(text: 'Mining'),
]
),
new TabBarView(
children: [
new Tab(child: new General()),
new Tab(child: new Mining()),
],
),
],
),
)
)
],
),
),
);
}
}
Text("Controls above tabs"),
DefaultTabController(
length: 2,
child: SizedBox(
height: 100.0,
child: Column(
children: <Widget>[
TabBar(
tabs: <Widget>[
Tab(
text: "tab1",
),
Tab(
text: "tab2",
)
],
),
Expanded(
child: TabBarView(
children: <Widget>[
Container(
color: Colors.green,
),
Container(
color: Colors.yellow,
),
],
),
),
],
),
),
),