body안에서 tabbar 사용하기
import 'package:flutter/material.dart';
class NestedTabBar extends StatefulWidget {
@override
_NestedTabBarState createState() => _NestedTabBarState();
}
class _NestedTabBarState extends State<NestedTabBar>
with TickerProviderStateMixin {
TabController _nestedTabController;
@override
void initState() {
super.initState();
_nestedTabController = new TabController(length: 5, vsync: this);
}
@override
void dispose() {
super.dispose();
_nestedTabController.dispose();
}
@override
Widget build(BuildContext context) {
double screenHeight = MediaQuery.of(context).size.height;
return Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
TabBar(
controller: _nestedTabController,
indicatorColor: Colors.teal,
labelColor: Colors.teal,
unselectedLabelColor: Colors.black54,
isScrollable: true,
tabs: <Widget>[
Tab(
text: "One",
),
Tab(
text: "Two",
),
Tab(
text: "Three",
),
Tab(
text: "Four",
),
Tab(
text: "Five",
),
],
),
Container(
height: screenHeight * 0.70,
margin: EdgeInsets.only(left: 16.0, right: 16.0),
child: TabBarView(
controller: _nestedTabController,
children: <Widget>[
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
color: Colors.blueAccent,
),
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
color: Colors.orangeAccent,
),
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
color: Colors.greenAccent,
),
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
color: Colors.indigoAccent,
),
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
color: Colors.redAccent,
),
),
],
),
)
],
);
}
}
'ETC > Flutter' 카테고리의 다른 글
[flutter] alert(확인창) 띄우기 (0) | 2021.11.06 |
---|---|
[flutter] Row(행) 과 Column(열) 위젯 이란? (0) | 2021.11.06 |
[flutter] DropdownButton 사용하기 (0) | 2021.11.06 |
[flutter] 달력 띄우기(DatePicker) (0) | 2021.10.19 |
[flutter] 변경된 스낵바(SnackBar) 문법 (0) | 2021.10.19 |
[flutter] 변경된 버튼들(FlatButton,Outline Button,RaisedButton) (0) | 2021.10.19 |
댓글