Skip to content

Instantly share code, notes, and snippets.

@SteveAlexander
Created July 3, 2018 11:55
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 SteveAlexander/92a2f11584456e529f67e1453dd18063 to your computer and use it in GitHub Desktop.
Save SteveAlexander/92a2f11584456e529f67e1453dd18063 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
home: new DefaultTabController(
length: 3,
child: new SafeArea(
child: new Scaffold(
bottomNavigationBar: new Container(
child: new TabBar(
labelColor: Colors.black,
labelStyle: TextStyle(fontSize: 20.0),
tabs: [
Text('foo'),
Text('bar'),
Text('baz'),
]
),
),
body: new TabBarView(
children: [
new FooPage(),
new BarPage(),
new BazPage(),
]
)
)
)
)
)
);
}
class FooPage extends StatefulWidget {
@override
FooState createState() => new FooState();
}
class FooState extends State<FooPage> with AutomaticKeepAliveClientMixin<FooPage> {
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
return new Center(
child: new Text('foo')
);
}
}
class BarPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Center(
child: new Text('bar')
);
}
}
class BazPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Center(
child: new Text('baz')
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment