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,
),
);
}
}