-
-
Notifications
You must be signed in to change notification settings - Fork 78
/
tabs_widget.dart
70 lines (65 loc) · 1.89 KB
/
tabs_widget.dart
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
69
70
import 'package:flutter/material.dart';
import 'package:flutter_widget_guide/Code.dart';
import 'package:flutter_widget_guide/CodeScreen.dart';
import 'package:flutter_widget_guide/utils.dart';
import '../Ads.dart';
class TabsWidget extends StatefulWidget {
@override
_TabsWidgetState createState() => _TabsWidgetState();
}
class _TabsWidgetState extends State<TabsWidget> {
final List<Tab> myTabs = <Tab>[
Tab(text: "Tab 1", icon: Icon(Icons.looks_one)),
Tab(text: "Tab 2", icon: Icon(Icons.looks_two)),
];
@override
void initState() {
Ads.hideBannerAd();
super.initState();
}
@override
Widget build(BuildContext context) {
//Wrap everything in DefaultTabController
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(
'Tabs Widget',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
fontFamily: Utils.ubuntuRegularFont),
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.code),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
CodeScreen(code: Code.tabsWidgetCode))),
)
],
//Specify the tabs for your view
bottom: TabBar(
tabs: myTabs,
indicatorColor: Theme.of(context).backgroundColor,
),
),
//Provide each tab with its own content
body: TabBarView(
children: myTabs.map((Tab tab) {
return Center(
child: Text(
'This is the ${tab.text}',
style: const TextStyle(fontSize: 16),
),
);
}).toList(),
),
),
);
}
}