Flutter - 당근 마켓 만들어 보기 - 2

Gun·2023년 10월 19일
0

Flutter

목록 보기
19/25
post-thumbnail

main_screens.dart


import 'package:class_carrot_market_v1/screens/home/home_screen.dart';
import 'package:class_carrot_market_v1/screens/my_carrot/my_carrot_screen.dart';
import 'package:class_carrot_market_v1/screens/near_me/near_me.dart';
import 'package:class_carrot_market_v1/screens/neighorhood_life/neighorhood_lift_screen.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'chatting/chatting_screen.dart';

class MainScreens extends StatefulWidget {
  const MainScreens({super.key});

  
  State<MainScreens> createState() => _MainScreensState();
}

class _MainScreensState extends State<MainScreens> {
  int _selectedIndex = 0;

  
  Widget build(BuildContext context) {
    return Scaffold(
      body: IndexedStack(
        index: _selectedIndex,
        children: [
          HomeScreen(),
          NeighborhoodLifeScreen(),
          NearMe(),
          ChattingScreen(),
          MyCarrotScreen(),
        ],
      ),
      bottomNavigationBar: BottomNavigationBar(
        backgroundColor: Colors.white,
        type: BottomNavigationBarType.fixed,
        currentIndex: _selectedIndex,
        onTap: (newIndex) {
          setState(() {
            _selectedIndex = newIndex;
          });
        },
        items: [
          BottomNavigationBarItem(icon: Icon(CupertinoIcons.home), label: '홈'),
          BottomNavigationBarItem(
              icon: Icon(CupertinoIcons.square_on_square), label: '동네생활'),
          BottomNavigationBarItem(
              icon: Icon(CupertinoIcons.placemark), label: '내 근처'),
          BottomNavigationBarItem(
              icon: Icon(CupertinoIcons.chat_bubble_2), label: '채팅'),
          BottomNavigationBarItem(
              icon: Icon(CupertinoIcons.person), label: '나의 당근'),
        ],
      ),
    );
  }
}

0개의 댓글