country_code_picker

一个用于显示国家代码选择器的 Flutter 包。

country_code_pickerz

country_code_picker

用法

只需将组件放置在您的应用程序中,并设置onChanged回调。


@override
 Widget build(BuildContext context) => new Scaffold(
     body: new Center(
       child: new CountryCodePicker(
         onChanged: print,
         // Initial selection and favorite can be one of code ('IT') OR dial_code('+39')
         initialSelection: 'IT',
         favorite: ['+39','FR'],
         // optional. Shows only country name and flag
         showCountryOnly: false,
       ),
     ),
 );

注意:您的onChanged函数可以是如下类型的任何函数

(CountryCode)->dynamic

示例


void _onCountryChange(CountryCode countryCode) {
    //Todo : manipulate the selected country code here
    print("New Country selected: " + countryCode.toString());
  }
  

GitHub

https://github.com/imtoori/CountryCodePicker