nepali_address 1.0.0 copy "nepali_address: ^1.0.0" to clipboard
nepali_address: ^1.0.0 copied to clipboard

It listed all the addresses of nepal.

example/lib/main.dart

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

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Nepali Address',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const HomePage(),
    );
  }
}

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

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  TextEditingController wardController = TextEditingController();
  List<String> fullAddress = [];
  bool isAddressSelected = false;

  Address address = addressList;

  void checkAddress() {
    if (fullAddress.length > 1 && wardController.text.isNotEmpty) {
      isAddressSelected = true;
    }
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Column(
          children: [
            AddressContainer(
              isRoundedBorder: true,
              selectDistrict: (String district) {
                fullAddress.add('District ' + district);
              },
              selectProvince: (String province) {
                fullAddress.clear();
                fullAddress.add('\n Province ' + province);
              },
              selectMunicipality: (String municipality) {
                fullAddress.add('\n Municipality ' + municipality);
              },
              wardController: wardController,
              isNepali: false,
            ),
            ElevatedButton(
                onPressed: () => checkAddress(),
                child: const Text('Show Address')),
            if (isAddressSelected)
              for (int i = 0; i < fullAddress.length; i++) ...[
                Text(fullAddress[i] + '\n')
              ]
            else
              const Text('No Address Selected'),
            Text('Ward :' + wardController.text),
          ],
        ),
      ),
    );
  }
}
2
likes
110
pub points
2%
popularity

Publisher

unverified uploader

It listed all the addresses of nepal.

Homepage

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, path_provider

More

Packages that depend on nepali_address