nation_code_picker 1.1.0 copy "nation_code_picker: ^1.1.0" to clipboard
nation_code_picker: ^1.1.0 copied to clipboard

This package provides a widget that allows you to select country dialing codes in your applications.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:nation_code_picker/flag_component.dart';
import 'package:nation_code_picker/nation_code_picker.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Nation Code Picker'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  NationCodes _selectedNationCode = NationCodes.tr;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            NationCodePicker(
              defaultNationCode: _selectedNationCode,
              dialCodeColor: Colors.deepPurple,
              dialCodeFontWeight: FontWeight.bold,
              dialCodeFontFamily: 'Ubuntu',
              onNationSelected: (p0) {
                setState(() {
                  _selectedNationCode = p0;
                });
              },
            ),
            Padding(
              padding: const EdgeInsets.all(20),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  const Text("Selected nation data:"),
                  ListTile(
                    leading: Text(_selectedNationCode.code,
                        style: const TextStyle(fontSize: 20)),
                    title: Text(_selectedNationCode.name,
                        style: const TextStyle(fontSize: 20)),
                    trailing: Text(_selectedNationCode.dialCode,
                        style: const TextStyle(fontSize: 20)),
                  ),
                ],
              ),
            ),
            const SizedBox(height: 30),
            const Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text('FlagComponent'),
                FlagComponent(nation: NationCodes.tr),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
22
likes
160
pub points
73%
popularity

Publisher

verified publisherenescerrahoglu.com

This package provides a widget that allows you to select country dialing codes in your applications.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

equatable, flutter

More

Packages that depend on nation_code_picker