Last active
June 23, 2017 18:42
-
-
Save collinjackson/2a69776822f2f6b837f6374f24cae039 to your computer and use it in GitHub Desktop.
Tab bug demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(new MaterialApp( | |
home: new MyHomePage(), | |
)); | |
} | |
class TabbedPage extends StatelessWidget { | |
TabbedPage({ this.pageIndex, this.tabCount }); | |
final int pageIndex; | |
final int tabCount; | |
Widget build(BuildContext context) { | |
return new DefaultTabController( | |
length: tabCount, | |
child: new Column( | |
children: <Widget>[ | |
new Container( | |
color: Theme.of(context).primaryColor, | |
child: new TabBar( | |
tabs: new List<Tab>.generate(tabCount, (int tabIndex) { | |
return new Tab(text: 'Tab ${pageIndex}-${tabIndex}'); | |
}), | |
), | |
), | |
new Expanded( | |
child: new TabBarView( | |
children: new List<Widget>.generate(tabCount, (int tabIndex) { | |
return new Center( | |
child: new Text('View ${pageIndex}-${tabIndex}'), | |
); | |
}), | |
), | |
), | |
], | |
), | |
); | |
} | |
} | |
class MyHomePage extends StatelessWidget { | |
Widget build(BuildContext context) { | |
return new PageView( | |
children: <Widget>[ | |
new Scaffold( | |
appBar: new AppBar( | |
title: new Text('Page 0'), | |
), | |
body: new TabbedPage(pageIndex: 1, tabCount: 3), | |
), | |
new Scaffold( | |
appBar: new AppBar( | |
title: new Text('Page 1'), | |
), | |
body: new TabbedPage(pageIndex: 2, tabCount: 4), | |
), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment