country_state_picker 0.0.4 copy "country_state_picker: ^0.0.4" to clipboard
country_state_picker: ^0.0.4 copied to clipboard

A Package for Picking Countries and States from a Dropdown Field. Compactible with IOS,ANDROID AND WEB. Feel free to make PR's and suggestions.

example/lib/main.dart

import 'package:flutter/material.dart';

// IMPORT COUNTRY STATE PICKER
import 'package:country_state_picker/country_state_picker.dart';

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

class AddressPicker extends StatefulWidget {
  const AddressPicker({Key? key}) : super(key: key);

  @override
  State<AddressPicker> createState() => _AddressPickerState();
}

class _AddressPickerState extends State<AddressPicker> {
  // DECLARE STATE VARIABLES
  String? state;
  String? country;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: SafeArea(
          child: SingleChildScrollView(
            padding: const EdgeInsets.symmetric(horizontal: 16),
            child: Column(
              children: [
                // IMPLEMENT WIDGET
                CountryStatePicker(
                  onCountryChanged: (ct) => setState(() {
                    country = ct;
                    state = null;
                  }),
                  onStateChanged: (st) => setState(() {
                    state = st;
                  }),
                ),
                const SizedBox(height: 50),
                if (country != null)
                  Text("Country = $country",
                      style: const TextStyle(fontSize: 18)),
                const SizedBox(height: 40),
                if (state != null)
                  Text("Country = $state", style: const TextStyle(fontSize: 18))
              ],
            ),
          ),
        ),
      ),
    );
  }
}
3
likes
150
pub points
84%
popularity

Publisher

verified publisheracloe.com

A Package for Picking Countries and States from a Dropdown Field. Compactible with IOS,ANDROID AND WEB. Feel free to make PR's and suggestions.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on country_state_picker