ZetaPhoneInput constructor
- Key? key,
- bool? rounded,
- ValueChanged<
PhoneNumber?> ? onFieldSubmitted, - FormFieldSetter<
PhoneNumber> ? onSaved, - PhoneNumber? initialValue,
- FormFieldValidator<
PhoneNumber> ? validator, - @Deprecated('Use onChange instead. ' 'Deprecated as of 0.15.0') ValueChanged<
PhoneNumber?> ? onChanged, - ValueChanged<
PhoneNumber?> ? onChange, - ZetaFormFieldRequirement? requirementLevel = ZetaFormFieldRequirement.none,
- String? label,
- @Deprecated('Use hintText instead. ' 'Deprecated as of 0.15.0') String? hint,
- String? hintText,
- @Deprecated('Use disabled instead. ' 'Deprecated as of 0.15.0') bool enabled = true,
- bool disabled = false,
- @Deprecated('Use errorText instead. ' 'Deprecated as of 0.15.0') bool hasError = false,
- String? errorText,
- @Deprecated('Use initialValue instead. ' 'Deprecated as of 0.15.0') String? initialCountry,
- List<
String> ? countries, - ZetaWidgetSize size = ZetaWidgetSize.medium,
- @Deprecated('Set this as part of the initial value instead. ' 'Deprecated as of 0.15.0') String? countryDialCode,
- @Deprecated('Set this as part of the initial value instead. ' 'enabled is deprecated as of 0.15.0') String? phoneNumber,
- @Deprecated('Country search hint is deprecated as of 0.15.0') String? countrySearchHint,
- String? selectCountrySemanticLabel,
- AutovalidateMode? autovalidateMode,
Constructor for ZetaPhoneInput.
Implementation
ZetaPhoneInput({
super.key,
bool? rounded,
super.onFieldSubmitted,
super.onSaved,
super.initialValue,
super.validator,
@Deprecated('Use onChange instead. ' 'Deprecated as of 0.15.0') ValueChanged<PhoneNumber?>? onChanged,
super.onChange,
super.requirementLevel = ZetaFormFieldRequirement.none,
this.label,
@Deprecated('Use hintText instead. ' 'Deprecated as of 0.15.0') String? hint,
this.hintText,
@Deprecated('Use disabled instead. ' 'Deprecated as of 0.15.0') bool enabled = true,
super.disabled = false,
@Deprecated('Use errorText instead. ' 'Deprecated as of 0.15.0') bool hasError = false,
this.errorText,
@Deprecated('Use initialValue instead. ' 'Deprecated as of 0.15.0') String? initialCountry,
this.countries,
this.size = ZetaWidgetSize.medium,
@Deprecated('Set this as part of the initial value instead. ' 'Deprecated as of 0.15.0') String? countryDialCode,
@Deprecated('Set this as part of the initial value instead. ' 'enabled is deprecated as of 0.15.0')
String? phoneNumber,
@Deprecated('Country search hint is deprecated as of 0.15.0') String? countrySearchHint,
@Deprecated('Deprecated as of 0.15.0') bool? useRootNavigator,
this.selectCountrySemanticLabel,
super.autovalidateMode,
}) : super(
builder: (field) {
final _ZetaPhoneInputState state = field as _ZetaPhoneInputState;
final colors = Zeta.of(field.context).colors;
final spacing = Zeta.of(field.context).spacing;
final newRounded = rounded ?? field.context.rounded;
return InternalTextInput(
label: label,
hintText: hintText,
errorText: field.errorText ?? errorText,
size: size,
controller: state.controller,
requirementLevel: requirementLevel,
rounded: rounded,
disabled: disabled,
focusNode: state._inputFocusNode,
onSubmit: onFieldSubmitted != null ? (_) => onFieldSubmitted(field.value) : null,
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r'[\d\s\-]'))],
keyboardType: TextInputType.phone,
prefixText: state._selectedCountry.dialCode,
borderRadius: BorderRadius.only(
topRight: newRounded ? Radius.circular(spacing.minimum) : Radius.zero,
bottomRight: newRounded ? Radius.circular(spacing.minimum) : Radius.zero,
),
externalPrefix: ZetaDropdown(
offset: Offset(0, spacing.medium),
onChange: !disabled ? state.onDropdownChanged : null,
value: state._selectedCountry.dialCode,
onDismissed: state.onDropdownDismissed,
items: state._dropdownItems,
builder: (context, selectedItem, dropdowncontroller) {
final borderSide = BorderSide(
color: disabled ? colors.borderDefault : colors.borderSubtle,
);
return GestureDetector(
onTap: !disabled ? dropdowncontroller.toggle : null,
child: Container(
constraints: BoxConstraints(
maxHeight: size == ZetaWidgetSize.large
? Zeta.of(context).spacing.xl_8
: Zeta.of(context).spacing.xl_6,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: newRounded ? Radius.circular(spacing.minimum) : Radius.zero,
bottomLeft: newRounded ? Radius.circular(spacing.minimum) : Radius.zero,
),
border: Border(
left: borderSide,
top: borderSide,
bottom: borderSide,
),
color: disabled ? colors.surfaceDisabled : colors.surfaceDefault,
),
child: Column(
children: [
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: EdgeInsets.only(
left: spacing.medium,
right: spacing.small,
),
child: selectedItem?.icon,
),
ZetaIcon(
!dropdowncontroller.isOpen ? ZetaIcons.expand_more : ZetaIcons.expand_less,
color: !disabled ? colors.iconDefault : colors.iconDisabled,
size: Zeta.of(context).spacing.xl,
),
],
),
),
],
),
),
);
},
),
);
},
);