Skip to content

Instantly share code, notes, and snippets.

@HansMuller
Last active July 17, 2019 08:18
Show Gist options
  • Save HansMuller/4410e538db815fec41dda23da84a08f4 to your computer and use it in GitHub Desktop.
Save HansMuller/4410e538db815fec41dda23da84a08f4 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
TabController _tabController;
final GlobalKey<State> _item0Key = new GlobalKey<State>(debugLabel: 'item0Key');
@override
void initState() {
super.initState();
_tabController = new TabController(length: 3, vsync: this);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(
children: <Widget>[
TabBar(
controller: _tabController,
labelColor: Colors.blue,
tabs: [
Tab(text: "Tab0"),
Tab(text: "Tab1"),
Tab(text: "Tab2"),
],
),
Expanded(
child: TabBarView(
controller: _tabController,
children: <Widget>[
Center(key: _item0Key, child: Text('Tab0')),
Center(child: Text('Tab1')),
Center(child: Text('Tab2')),
],
),
)
],
),
),
);
}
}
void main() {
runApp(MaterialApp(home: HomePage()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment