Skip to content

Instantly share code, notes, and snippets.

@collinjackson
Last active June 23, 2017 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save collinjackson/2a69776822f2f6b837f6374f24cae039 to your computer and use it in GitHub Desktop.
Save collinjackson/2a69776822f2f6b837f6374f24cae039 to your computer and use it in GitHub Desktop.
Tab bug demo
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