// πŸ‘οΈ λΉ„λ°€λ²ˆν˜Έ μž…λ ₯μ°½ - 였λ₯Έμͺ½ 눈 μ•„μ΄μ½˜μ„ λˆ„λ₯΄κ³  μžˆλŠ” λ™μ•ˆλ§Œ ν‰λ¬ΈμœΌλ‘œ 보여쀀닀. // ν† κΈ€ν˜•(λˆŒλŸ¬μ„œ 계속 보기) λŒ€μ‹  "ν™€λ“œ"둜 λ§Œλ“  이유: 손을 λ–ΌλŠ” μˆœκ°„ λ°”λ‘œ λ‹€μ‹œ κ°€λ €μ Έμ„œ // λˆ„κ°€ μ˜†μ—μ„œ 보더라도 짧게 ν™•μΈλ§Œ ν•˜κ³  끝낼 수 μžˆλ‹€. import 'package:flutter/material.dart'; class HoldToRevealPasswordField extends StatefulWidget { final TextEditingController controller; final String labelText; final String? hintText; final IconData prefixIcon; final bool autofocus; final TextInputType? keyboardType; final TextInputAction? textInputAction; final ValueChanged? onSubmitted; const HoldToRevealPasswordField({ super.key, required this.controller, required this.labelText, this.hintText, this.prefixIcon = Icons.lock, this.autofocus = false, this.keyboardType, this.textInputAction, this.onSubmitted, }); @override State createState() => _HoldToRevealPasswordFieldState(); } class _HoldToRevealPasswordFieldState extends State { bool _revealed = false; void _setRevealed(bool value) { if (_revealed != value) setState(() => _revealed = value); } @override Widget build(BuildContext context) { return TextField( controller: widget.controller, obscureText: !_revealed, autofocus: widget.autofocus, keyboardType: widget.keyboardType, textInputAction: widget.textInputAction, onSubmitted: widget.onSubmitted, decoration: InputDecoration( labelText: widget.labelText, hintText: widget.hintText, border: const OutlineInputBorder(), prefixIcon: Icon(widget.prefixIcon), suffixIcon: GestureDetector( behavior: HitTestBehavior.opaque, onTapDown: (_) => _setRevealed(true), onTapUp: (_) => _setRevealed(false), onTapCancel: () => _setRevealed(false), child: Icon( _revealed ? Icons.visibility_rounded : Icons.visibility_off_rounded, color: Colors.grey, ), ), ), ); } }