phone input
flutter phone input integrated with flutter internationalization.
features
- totally cross platform, this is a dart only package / dependencies
- internationalization support, without bloated json with all translations.
- phone number validation
- extends flutter’s formfield
- uses dart phone_numbers_parser for parsing
demo
demo available at https://cedvdb.github.io/phone_form_field/
usage
phoneformfield(
initialvalue: phonenumber,
autofocus: true,
decoration: inputdecoration(
labeltext: 'phone',
border: outlineinputborder(),
// ...
),
onchanged: (p) => setstate(() => phonenumber = p!),
onsaved: (p) => setstate(() => phonenumber = p),
phonenumbertype: null, // could be phonenumbertype.mobile or phonenumbertype.fixed for more specific validation
),
internationalization
include the delegate
return materialapp(
localizationsdelegates: [
...globalmateriallocalizations.delegates,
phonefieldlocalization.delegate
],
supportedlocales: [
const locale('en', ''),
const locale('es', ''),
const locale('fr', ''),
const locale('ru', ''),
// ...
],
tnat’s it.
a bunch of languages are built-in:
- 'ar',
- 'de',
- 'en',
- 'es',
- 'fr',
- 'hin',
- 'it',
- 'nl',
- 'pt',
- 'ru',
- 'zh',
if one of the language you target is not supported you can submit a pull request with the translated file in assets/translation
Comments are closed.