import 'package:flutter/material.dart';
class TabOne extends StatefulWidget {
@override
_TabOneState createState() => _TabOneState();
}
class _TabOneState extends State<TabOne> {
String text = "게임 시작해보세요!";
void changeText(){
setState(() {
text = "변경된 텍스트";
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body : Center(
child: Text(text,
style: TextStyle(
fontSize: 40.0
),
),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.info),
onPressed: changeText,
),
);
}
}
import 'package:flutter/material.dart';
import 'package:flutterappssssss/Tab_one.dart';
import 'package:flutterappssssss/Tab_three.dart';
import 'package:flutterappssssss/Tab_two.dart';
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
int _slectedTab = 0;
List<Widget> _widgets = <Widget>[
tab_one(),
tab_two(),
tab_three(),
];
void _Tapped(int index) {
setState(() {
_slectedTab = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: _widgets.elementAt(_slectedTab),
),
bottomNavigationBar: BottomNavigationBar(
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.bubble_chart, color: Colors.blue,),
title: Text('초급', style: TextStyle(color: Colors.blue),),
),
BottomNavigationBarItem(
icon: Icon(Icons.bubble_chart, color: Colors.pink,),
title: Text('중급', style: TextStyle(color: Colors.pink),),
),
BottomNavigationBarItem(
icon: Icon(Icons.bubble_chart, color: Colors.red,),
title: Text('고급', style: TextStyle(color: Colors.red),),
)
],
currentIndex: _slectedTab,
onTap: _Tapped,
),
);
}
}
'인프런 - 강의 > 플루터로 앱 만들기 고고(입문)' 카테고리의 다른 글
15 - My 아이돌 앱 (0) | 2020.04.27 |
---|---|
14 - 커플게임 4 (0) | 2020.04.24 |
12 - 커플게임 2 (0) | 2020.04.23 |
11 - 커플게임 1 (0) | 2020.04.22 |
10 - 369게임 3 (0) | 2020.04.22 |