Skip to content

Instantly share code, notes, and snippets.

@shyjuzz
Last active May 18, 2018 12:48
Show Gist options
  • Save shyjuzz/48d48520eda4557fd7739c2cd5382fbb to your computer and use it in GitHub Desktop.
Save shyjuzz/48d48520eda4557fd7739c2cd5382fbb to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
class CustomBottom extends StatefulWidget {
@override
AppState createState() => AppState();
}
class AppState extends State<CustomBottom> with SingleTickerProviderStateMixin {
TabController _controller;
@override
void initState() {
super.initState();
_controller = new TabController(length: 2, vsync: this);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Budget'),),
body: TabBarView(
controller: _controller,
children: <Widget>[new NewPage('First'), new NewPage('Second')],
),
bottomNavigationBar: new Material(
child: TabBar(
labelColor: Colors.red,
indicatorColor: Colors.red,
unselectedLabelColor: Colors.grey,
controller: _controller,
tabs: <Widget>[
new MyTab(
Icon(
Icons.info,
),
'Details',
),
new MyTab(Icon(Icons.access_time), 'Timeline', false)
],
),
),
);
}
}
class MyTab extends StatelessWidget implements Tab {
final Icon _icon;
final String _text;
final bool _dividerRequired;
MyTab(this._icon, this._text, [this._dividerRequired = true]);
@override
Widget build(BuildContext context) {
return _dividerRequired
? Row(
children: <Widget>[
new Expanded(
child: Tab(
icon: _icon,
text: _text,
),
flex: 1,
),
new Container(
width: 1.0,
height: 30.0,
color: Colors.grey,
)
],
)
: Tab(
icon: _icon,
text: _text,
);
}
// TODO: implement child
@override
Widget get child => null;
// TODO: implement icon
@override
Widget get icon => _icon;
// TODO: implement text
@override
String get text => _text;
}
class NewPage extends StatelessWidget {
final String title;
NewPage(this.title);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text(title),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment