forked from ibhavikmakwana/FlutterPlayground
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTabBarExample.dart
More file actions
68 lines (60 loc) · 1.48 KB
/
TabBarExample.dart
File metadata and controls
68 lines (60 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
class TabBarExample extends StatefulWidget {
final String title;
TabBarExample({Key key, this.title}) : super(key: key);
@override
_TabBarExampleState createState() => _TabBarExampleState();
}
class _TabBarExampleState extends State<TabBarExample>
with SingleTickerProviderStateMixin {
TabController _tabController;
@override
void initState() {
_tabController = TabController(length: 3, vsync: this);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
bottom: TabBar(
tabs: [
Tab(
text: "Tab 1",
),
Tab(
text: "Tab 2",
),
Tab(
text: "Tab 3",
),
],
controller: _tabController,
),
),
body: TabBarView(
children: <Widget>[
Container(
color: Colors.orangeAccent,
),
Container(
color: Colors.redAccent,
),
Container(
color: Colors.blueAccent,
),
],
controller: _tabController,
),
);
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
}