플로팅 버튼 사용 (FloatingActionButton)

밥이·2022년 5월 12일
0

아이콘 사용
child: Icon(
		// Icons.plus_one, // +1 아이콘
    	// Icons.add, // + 아이콘
		Icons.remove_outlined,
		color: Colors.white,
		),
// 플로팅 버튼 생성
floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            count == 0 ? count = 0 : count--;
          });
        },
        child: const Icon(
          // Icons.plus_one, // +1 아이콘
          Icons.remove_outlined,
          color: Colors.white,
        ),
      ),
      
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          ElevatedButton(
            onPressed: () {
              setState(() {
                count++;
              }); // 빌드가 다시 호출되서 리렌더링됨
            },
            child: const Text("+"),
          ),
          Center(
            child: Text('$count'),
          )
        ],
      ),

0개의 댓글