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

Autocomplete field for postal codes in any country around the world

example/lib/main.dart

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

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

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

  @override
  State<MainApp> createState() => _MainAppState();
}

class _MainAppState extends State<MainApp> {
  PostalCode? _postalCode;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Container(
            constraints: const BoxConstraints(maxWidth: 400),
            padding: const EdgeInsets.symmetric(horizontal: 24),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                Text(
                  _postalCode?.city ?? "nothing selected",
                  style: Theme.of(context).textTheme.titleLarge,
                ),
                const SizedBox(height: 36),
                PostalCodeField(
                  countryCode: "cz",
                  onSelected: (postalCode) {
                    setState(() {
                      _postalCode = postalCode;
                    });
                  },
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
4
likes
160
points
123
downloads

Publisher

unverified uploader

Weekly Downloads

Autocomplete field for postal codes in any country around the world

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on postal_code