728x90
ElevatedButton은 플러터 내에서 입체적인 폼을 가진 버튼입니다.
색상을 바꾸는 방법은 ButtonStyle 객체에 각종 Color 파라미터를 넘겨주어 색상을 변경합니다.
backgroundColor : 버튼의 기본 색상
overlayColor : 버튼 선택 시 표현할 색상
shadowColor : 버튼 선택 시 표현할 그림자 색상
MaterialStateProperty.all(Colors."사용할 컬러") : 전달할 컬러 객체
ElevatedButton(
onPressed: () {
print('버튼 선택 됨');
},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(Colors.green), //기본 색상
overlayColor: MaterialStateProperty.all<Color>(Colors.lightGreen), //선택 시 표현할 색상
shadowColor: MaterialStateProperty.all<Color>(Colors.cyan), //선택 시 표현할 그림자 색상
),
child: Container(
width: 150,
height: 50,
child: Row(
children: [
Icon(Icons.add_circle),
SizedBox(width: 5),
Text('새 게시물 추가')
],
),
),
)
728x90
'Mobile > Flutter' 카테고리의 다른 글
[Flutter]앱 다국어(한국어) 지원하기 (0) | 2023.11.16 |
---|---|
[Flutter] 위젯 터치 막기 (AbsorbPointer) (0) | 2023.11.15 |
[Flutter] StatefulWidget 내에서 생성자를 통해 받아온 값 활용하기 (0) | 2023.11.13 |
[Flutter] 상수 (const, final) (0) | 2023.11.07 |
[Flutter] 의존성 (패키지) 추가하기 (0) | 2023.11.01 |
댓글