counterSuffixIcon method
Implementation
Widget? counterSuffixIcon() {
if (widget.data.suffix != null) return widget.data.suffix;
// 密码输入框后的眼睛
if (widget.data.validatorType == HbValidatorType.confirmPass ||
widget.data.validatorType == HbValidatorType.password) {
return Icon(
_hidePassword ? Icons.visibility_off : Icons.visibility,
size: 18.w,
).pr(10.w).onGestureTap(() {
_hidePassword = !_hidePassword;
if (mounted) setState(() {});
});
} else if (widget.data.validatorType == HbValidatorType.code) {
// 发送按钮
return Padding(
padding: EdgeInsets.only(right: 10.w),
child: StreamBuilder<Object>(
stream: _streamController.stream,
builder: (context, snapshot) {
if (snapshot.data != null && snapshot.data != 0) {
return HbButton(height: 28.w, text: '${snapshot.data}s');
} else {
// 发送验证码
return HbButton(
height: 28.w,
text: HbCommonLocalizations.current.send,
onTap: _sendCode,
);
}
},
),
);
} else {
// 清除按钮, 存在内容时才显示
return ValueListenableBuilder(
valueListenable: _controller,
builder: (context, value, __) {
return Visibility(
visible: value.text.isNotEmpty,
child: Icon(
Icons.cancel,
size: 16.w,
color: Theme.of(context).colorScheme.onSurface,
).pr(10.w).onGestureTap(() {
_controller.clear();
}),
);
},
);
}
}