dialcodeselector 1.0.2 copy "dialcodeselector: ^1.0.2" to clipboard
dialcodeselector: ^1.0.2 copied to clipboard

Flutter package for selecting country dial code.

example/lib/main.dart

import 'package:dialcodeselector/dialcodeselector.dart';
import 'package:flutter/material.dart';

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Package Example App',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: const HomeView());
  }
}

class HomeView extends StatefulWidget {
  const HomeView({super.key});

  @override
  State<HomeView> createState() => _HomeViewState();
}

class _HomeViewState extends State<HomeView> {
  String? initialCountrCode;

  Country? selectedCountry;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: const Text("Home")),
        body: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 25),
          child: Center(
              child: TextFormField(
            decoration: InputDecoration(
                hintText: "Enter phone number",
                prefixIcon: DialCodeSelector(callback: (selectedCountry) {
                  //use selectedCountry from callback here, Country logo is Null here
                  print("Selected Country: ${selectedCountry.countryName}");
                })),
            onChanged: (String value) {},
          )),
        ));
  }
}
2
likes
0
pub points
31%
popularity

Publisher

unverified uploader

Flutter package for selecting country dial code.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on dialcodeselector