hifiaz / country-list-pick

Flutter package to show and pick country code
https://pub.dev/packages/country_list_pick
MIT License
77 stars 102 forks source link

add appBar builder and placeholder result builder instead of hardcoding it #23

Closed jpainam closed 4 years ago

jpainam commented 4 years ago

Hi, nice library,

could you provide an appBar builder and a placeholder result builder instead of hardcoding the appbar (currently, the title is centered) and the result of the selection. This is allow more custumization.

I can provide a pull request if you are willing to integrate it.

jpainam commented 4 years ago

Solve it by a pull request at #24

You can now create your own appBar instead of using the default, you can also change the default text (SEARCH, LAST PICK etc..) Here a simple use case for anyone interested

CountryListPick(
    appBar: AppBar(
          // create your own appBar, default appBar(blue, centerTitle)
       ),
        pickerBuilder: (context, CountryCode countryCode) {
              // create your own picker, the default is countryflag, country name, keyboard_arrow_down
              return Row(
                children: [
                  Image.asset(
                    countryCode.flagUri,
                    package: 'country_list_pick', // do not forget this 
                  ),
                  Text(countryCode.code),
                  Text(countryCode.dialCode),
                ],
              );
            },
            theme: CountryTheme(
              // create your own theme customization, check CountryTheme class for more details
              //searchText; 
              //searchHintText;
              //lastPickText;
            ),
            initialSelection: '+62',
            onChanged: (CountryCode code) {
              print(code.name);
              print(code.code);
              print(code.dialCode);
              print(code.flagUri);
            },         
     ),

You can use this by adding this line in your pubspec.yaml

country_list_pick:
    git: https://github.com/jpainam/country-list-pick.git