Skip to content

Instantly share code, notes, and snippets.

@betapcode
Last active December 21, 2018 08:07
Show Gist options
  • Save betapcode/6fbf9dbade5c5dd0e180175e33b77d5b to your computer and use it in GitHub Desktop.
Save betapcode/6fbf9dbade5c5dd0e180175e33b77d5b to your computer and use it in GitHub Desktop.
[flutter] build tabbar example 01
import 'package:flutter/material.dart';
class AudioTabsScreen extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return new _AudioTabsState();
}
}
class _AudioTabsState extends State<AudioTabsScreen> {
var _tabs = [
Tab(
//icon: Icon(Icons.directions_car),
text: "Car",
),
Tab(
//icon: Icon(Icons.directions_transit),
text: "Transit",
),
Tab(
//icon: Icon(Icons.directions_bike),
text: "Bike",
),
Tab(
//icon: Icon(Icons.directions_bike),
text: "Bike 2",
),
];
var _childrenTab = [
Icon(Icons.directions_transit),
Icon(Icons.directions_transit),
Icon(Icons.directions_bike),
Icon(Icons.directions_bus),
];
// C1
Widget build(context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Tabs Demo'),
),
body: new DefaultTabController(
length: 4,
child: new Column(
children: <Widget>[
new Container(
constraints: BoxConstraints(maxHeight: 150.0),
child: new Material(
color: Colors.indigo,
child: new TabBar(
tabs: _tabs,
),
),
),
new Expanded(
child: new TabBarView(
children: _childrenTab,
),
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment