<클릭 안되는 녀석들을 클릭되도록 만드는 방법>
<이미지>
1. pubspec.yaml 파일 설정 후 Pub get
flutter:
assets:
- assets/my_icon.png
- assets/background.png
Image(image: AssetImage('assets/background.png'));
+) fit 옵션
<Icon 배경색>
Container(
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: IconButton(
onPressed: () {},
icon: const Icon(Icons.camera),
),
),
<동그란 테두리>
Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.red,
),
borderRadius: BorderRadius.all(Radius.circular(20))
),
child: ...
)
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(40.0),
bottomRight: Radius.circular(40.0),
topLeft: Radius.circular(40.0),
bottomLeft: Radius.circular(40.0)),
),
child: ...
),
<Checkbox 설정>
Checkbox(
checkColor: Colors.white,
activeColor: Colors.green,
side:
BorderSide(width: 2, color: Colors.green),
value: _isChecked,
onChanged: (value) {
setState(() {
_isChecked = value;
});
},
),
<텍스트 입력창>
TextFormField(
decoration: const InputDecoration(
border: OutlineInputBorder(),
textAlign: TextAlign.end, //입력 위치 오른쪽
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.green,
))
),
//클릭된 상태의 테두리
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.orange,
),
),
// 커서 설정
cursorColor: Colors.orange,
cursorWidth: 3,
showCursor: true //커서 숨길려면 false
)
<TextField 기본 여백>
TextField(
keyboardType: TextInputType.number,
controller: textController,
decoration: InputDecoration(
isDense: true, //추가
border: OutlineInputBorder(),
contentPadding: EdgeInsets.all(10), //전부 10 padding 부여
),
),
<버튼 종류>
TextButton( onPressed: () { }, icon: Icon(Icons.add, size: 18), label: Text("TEXT"), child: Text("TEXT BUTTON"), )
OutlinedButton( onPressed: () { }, child: Text("OUTLINED BUTTON"), )
ElevatedButton( onPressed: () { }, child: Text('ELEVATED BUTTON'), )
final isSelected = <bool>[false, false, false]; ToggleButtons(
color: Colors.black.withOpacity(0.60),
selectedColor: Colors.black,
selectedBorderColor: Colors.black,
fillColor: Colors.black.withOpacity(0.08),
splashColor: Colors.black.withOpacity(0.12),
hoverColor: Colors.black.withOpacity(0.04),
borderRadius: BorderRadius.circular(2.0),
constraints: BoxConstraints(minHeight: 30.0),
isSelected: isSelected,
onPressed: (index) {
setState(() {
isSelected[index] = !isSelected[index];
});
},
children: [
Padding( padding: EdgeInsets.symmetric(horizontal: 16.0), child: Text('BTN 1'), ),
Padding( padding: EdgeInsets.symmetric(horizontal: 16.0), child: Text('BTN 2'), ),
Padding( padding: EdgeInsets.symmetric(horizontal: 16.0), child: Text('BTN 3'),
),
],
)
var isSelected = false;
var icon = Icons.favorite_border;
IconButton( icon: Icon(icon), color: Colors.white, onPressed: () {
setState(() {
isSelected = !isSelected;
icon = isSelected ? Icons.favorite : Icons.favorite_border;
});
},
)
<Floating Action Button 기본>
build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("FAB"),
),
floatingActionButton: FloatingActionButton(onPressed: () {
},),
);
}
Widget
<효과 버튼>
SizedBox(
width: 57.w,
height: 57.h,
child: MaterialButton(
color: Colors.deepOrangeAccent,
shape: CircleBorder(),
onPressed: () { },
child: Icon(Icons.camera_alt_outlined, color: Colors.white,),
),
),
감사합니다. 이런 정보를 나눠주셔서 좋아요.