FlatButton widget
[Ko]
- image에 버튼 기능 넣기 : FlatButton widget의 child로 Image.asset widget을 넣음.
- FlatButton 자체가 padding을 가지고 있으므로(Flutter Inspector에서 확인 가능) Image.asset에 적용된 padding은 삭제함.
- FlatButton widget에는 필수적으로 onPressed property에 실행 함수를 정의해야 함.
- 현재는 이미지 클릭시 print 함수가 실행되도록 설정했음.
- final code
Expanded(
// flex: 1,
child: FlatButton(
onPressed: () {
print('Left button got pressed.');
},
child: Image.asset('images/aaa.png')),
),
[En]
- Put button function on image: Insert Image.asset widget as child of FlatButton widget.
- Since FlatButton itself has padding (can be checked in the Flutter Inspector), padding applied to Image.asset is deleted.
- Execution function must be defined in onPressed property for FlatButton widget.
- Currently, the print function is set to execute when the image is clicked.
- final code
Expanded(
// flex: 1,
child: FlatButton(
onPressed: () {
print('Left button got pressed.');
},
child: Image.asset('images/aaa.png')),
),
'플러터(Flutter) > 플러터 위젯(Flutter Widget)' 카테고리의 다른 글
SingleChildScrollView (0) | 2020.03.19 |
---|---|
Slider, Customizing Widgets with Themes (0) | 2020.03.19 |
Expanded Widget to Create Flexible Layouts (0) | 2020.03.18 |
Card & ListTile Widget (0) | 2020.03.18 |
CircleAvatar (0) | 2020.03.18 |