dart 什么是国际电话领域的波澜?

9q78igpj  于 2023-07-31  发布在  其他
关注(0)|答案(2)|浏览(122)

什么是国际电话领域?一个国际电话领域Flutter的例子。可能的参数是什么?如何申请国际电话领域在Flutter为一个登录页面?

pbpqsu0x

pbpqsu0x1#

一个自定义的Flutter TextFormField输入国际电话号码沿着国家代码。这个小部件可以用来制作自定义文本字段,以采取任何国家的电话号码输入,以及从下拉菜单中选择国家代码的选项。
要应用intl_phone_field,请执行以下操作。在依赖项中将此添加到pubspec.yaml中:

intl_phone_field: ^3.0.1

字符串
导入以下软件包:

import'package:intl_phone_field/intl_phone_field.dart';


添加此代码:

Container(
                  padding: const EdgeInsets.all(8),
                  height: 80,
                  child:IntlPhoneField(
                    decoration: const InputDecoration(
                      counter: Offstage(),
                      labelText: 'Mobile Number',
                      border: OutlineInputBorder(
                        borderSide: BorderSide(),
                  ),
                ),
                initialCountryCode: 'IN',
                showDropdownIcon: true,
                dropdownIconPosition:IconPosition.trailing,
                onChanged: (phone) {
                  print(phone.completeNumber);
                },
              ),),


dropdownIconPosition:IconPosition.trailing是将下拉图标向右移动。下拉图标的默认位置在左侧。
这是我们可以在intl_phone_field中应用的参数

InternationalPhoneNumberInput({
Key key,
  this.selectorConfig = const SelectorConfig(),
  @required this.onInputChanged,
  this.onInputValidated,
  this.onSubmit,
  this.onFieldSubmitted,
  this.validator,
  this.onSaved,
  this.textFieldController,
  this.keyboardAction,
  this.keyboardType = TextInputType.phone,
  this.initialValue,
  this.hintText = 'Phone number',
  this.errorMessage = 'Invalid phone number',
  this.selectorButtonOnErrorPadding = 24,
  this.spaceBetweenSelectorAndTextField = 12,
  this.maxLength = 15,
  this.isEnabled = true,
  this.formatInput = true,
  this.autoFocus = false,
  this.autoFocusSearch = false,
  this.autoValidateMode = AutovalidateMode.disabled,
  this.ignoreBlank = false,
  this.countrySelectorScrollControlled = true,
  this.locale,
  this.textStyle,
  this.selectorTextStyle,
  this.inputBorder,
  this.inputDecoration,
  this.searchBoxDecoration,
  this.textAlign = TextAlign.start,
  this.textAlignVertical = TextAlignVertical.center,
  this.scrollPadding = const EdgeInsets.all(20.0),
  this.focusNode,
  this.cursorColor,
  this.autofillHints,
  this.countries
});

n9vozmp4

n9vozmp42#

InternationalPhoneNumberInput(inputBorder:InputBorder.none,selectorConfig:SelectorConfig(selectorType:PhoneInputSelectorType.DIALOG,),selectorTextStyle:文本样式(颜色:kWhitecolor),textStyle:文本样式(颜色:kWhitecolor),onInputChanged:(value){},keyboardType:keyboardType,),
试试这个:)

相关问题