InkWell
클래스를 extends해서 InkWellEx.clear
를 만들것 입니다. 이 위젯은 물방울 효과가 없는 클릭 이벤트를 실행합니다.
class InkWellEx extends InkWell {
const InkWellEx.clear({Key? key, onTap, child}) : super(key: key, onTap: onTap, child: child, splashColor: Colors.transparent);
}
InkWellEx.clear
에서 'clear'는 명명된 생성자의 이름이며, 다음 괄호 안에 위치한 {Key? key, onTap, child}는 해당 생성자의 파라미터입니다.
super 키워드는 부모 클래스의 생성자를 호출하는데 사용됩니다.
이 경우에는 InkWellEx
가 InkWell
클래스를 확장하고 있으므로, super는 InkWell의 생성자를 호출합니다.
InkWell
생성자는 여러 매개변수를 받는데, 그 중 key, onTap, child, splashColor를 받고 있습니다.
InkWellEx.clear
생성자는 {Key? key, onTap, child}
이 세 가지 매개변수를 입력받아 super를 호출하고 있습니다.InkWell
생성자에 전달하고, splashColor는 직접적으로 Colors.transparent를 전달하고 있습니다.완성된 코드는 InkWellEx.clear
위젯을 생성할 때 splashColor
는 항상 투명Colors.transparent
으로 설정되고, 나머지 세 가지 파라미터는 개발자가 제공하는 값을 사용하게 됩니다.
InkWellEx.clear(
onTap: () {
print('Button tapped!');
},
child: Text('Tap me'),
),