카카오톡 만들기

송민경's avatar
Apr 17, 2024
카카오톡 만들기

import 'package:flutter/material.dart'; import 'ui/holder/main_holder.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( home: MainHolder(), ); } }
// 여기 화면에 여러 페이지를 둘 수 있겠구나!! import 'package:bottom_app/ui/holder/first/first_page.dart'; import 'package:bottom_app/ui/holder/third/third_page.dart'; import 'package:flutter/material.dart'; class MainHolder extends StatefulWidget { const MainHolder({super.key}); @override State<MainHolder> createState() => _MainHolderState(); } class _MainHolderState extends State<MainHolder> { int _index = 0; @override Widget build(BuildContext context) { // 통신코드 return Scaffold( body: IndexedStack( index: _index, children: [ FirstPage(), SecondPage(), ThirdPage(), ], ), bottomNavigationBar: BottomNavigationBar( showSelectedLabels: false, showUnselectedLabels: false, selectedItemColor: Colors.deepOrange, unselectedItemColor: Colors.black, currentIndex: _index, // 선택된 아이콘에 색상 보여주기 items: [ // item 개수는 5개가 최대값, 2 최소값 BottomNavigationBarItem(icon: Icon(Icons.home), label: "홈"), BottomNavigationBarItem(icon: Icon(Icons.face), label: "사진"), BottomNavigationBarItem(icon: Icon(Icons.ac_unit), label: "개인정보"), ], onTap: (i) { print("클릭됨 ${i}"); _index = i; setState(() {}); }, ), ); } } class ThirdPage extends StatelessWidget { const ThirdPage({ super.key, }); @override Widget build(BuildContext context) { return Center(child: Text("Third Page")); } }
import 'package:flutter/material.dart'; class SecondPage extends StatelessWidget { const SecondPage({ super.key, }); @override Widget build(BuildContext context) { return Center(child: Text("Second Page")); } }
import 'package:flutter/material.dart'; class FirstPage extends StatelessWidget { const FirstPage({ super.key, }); @override Widget build(BuildContext context) { return ListView.builder( itemCount: 10, itemBuilder: (context, index) { return ListTile( title: Text("메인제목"), subtitle: Text("서브제목"), leading: Icon(Icons.person), ); }, ); } } 10:55 import 'package:flutter/material.dart'; class SecondPage extends StatelessWidget { const SecondPage({ super.key, }); @override Widget build(BuildContext context) { return Center(child: Text("Second Page")); } }
import 'package:flutter/material.dart'; class ThirdPage extends StatelessWidget { const ThirdPage({ super.key, }); @override Widget build(BuildContext context) { return Center(child: Text("Third Page")); } } class SecondPage extends StatelessWidget { const SecondPage({ super.key, }); @override Widget build(BuildContext context) { return Center(child: Text("Second Page")); } }
Share article

vosw1