country_codes 0.1.0 copy "country_codes: ^0.1.0" to clipboard
country_codes: ^0.1.0 copied to clipboard

outdated

Country codes is an helper package that provides country details given a particular localization, such as dial codes, ISO 3166 codes (alpha-2, alpha-3) and country names.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:flutter/services.dart';
import 'package:country_codes/country_codes.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await CountryCodes.init();
  runApp(CountryCodesExampleApp());
}

class CountryCodesExampleApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Country codes example app'),
        ),
        body: Builder(builder: (context) {
          CountryDetails details = CountryCodes.detailsForLocale();
          Locale locale = CountryCodes.getDeviceLocale();
          return Center(
              child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                  'Device locale: ${locale.languageCode}-${locale.countryCode}'),
              Text('Name: ${details.name}'),
              Text('Alpha 2: ${details.alpha2Code}'),
              Text('Dial Code: ${details.dialCode}'),
              SizedBox(
                width: 200.0,
                child: TextFormField(
                  keyboardType: TextInputType.phone,
                  inputFormatters: [DialCodeFormatter()],
                ),
              ),
            ],
          ));
        }),
      ),
    );
  }
}
105
likes
40
pub points
97%
popularity

Publisher

verified publishermiguelruivo.com

Country codes is an helper package that provides country details given a particular localization, such as dial codes, ISO 3166 codes (alpha-2, alpha-3) and country names.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on country_codes