cedvdb / phone_form_field

Flutter phone number input
https://pub.dev/packages/phone_form_field
MIT License
72 stars 100 forks source link

Change language #262

Closed saleh-aleid closed 2 months ago

saleh-aleid commented 2 months ago

class _PhoneFormField extends StatelessWidget {
  const _PhoneFormField({
    required this.controller,
    required this.locale,
  });

  final PhoneController controller;
  final Locale locale;

  @override
  Widget build(BuildContext context) {
    return AutofillGroup(
      child: Localizations.override(
        context: context,
        locale: const Locale('ar'),
        child: Builder(
          builder: (context) {
            log(locale.languageCode);
            return PhoneFormField(
              autofocus: false,
              autofillHints: const [AutofillHints.telephoneNumber],
              controller: controller,
              focusNode: FocusNode(),
              isCountryButtonPersistent: true,
              countrySelectorNavigator:
                  const CountrySelectorNavigator.bottomSheet(),
              validator: PhoneValidator.compose(
                [
                  PhoneValidator.required(context),
                  PhoneValidator.validMobile(context),
                ],
              ),
            );
          },
        ),
      ),
    );
  }
}