myanmar_administrative_areas 0.0.10 copy "myanmar_administrative_areas: ^0.0.10" to clipboard
myanmar_administrative_areas: ^0.0.10 copied to clipboard

outdated

Myanmar Administrative Areas, myanmar villages, myanmar townships, myanmar district, myanmar towns

example/lib/main.dart

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

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

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

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

class _MainAppState extends State<MainApp> {
  String? selectedValue1;
  String? selectedValue2;
  String? selectedValue3;

  List<String> items2 = [];
  List<String> items3 = [];
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Dropdown Example'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(32.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              buildDropdown1(),
              const SizedBox(height: 16),
              buildDropdown2(),
              const SizedBox(height: 16),
              buildDropdown3(),
              const SizedBox(
                height: 30.0,
              ),
              Row(
                children: [
                  Expanded(
                    child: FilledButton(
                        onPressed: () => {}, child: const Text("ပြီးပါပြီ")),
                  ),
                  const SizedBox(
                    height: 50.0,
                  ),
                ],
              ),
              (selectedValue1 != null &&
                      selectedValue2 != null &&
                      selectedValue3 != null)
                  ? Text(
                      "$selectedValue1\n$selectedValue2 မြို့နယ် \n$selectedValue3 ကျေးရွာ",
                      style: const TextStyle(fontSize: 20.0),
                      textAlign: TextAlign.center,
                    )
                  : Container()
            ],
          ),
        ),
      ),
    );
  }

  Widget buildDropdown1() {
    return DropdownButtonFormField<String>(
      value: selectedValue1,
      hint: const Text('ပြည်နယ် နှင့် တိုင်းရွေးပါ'),
      onChanged: (String? value) {
        setState(() {
          selectedValue1 = value!;
          selectedValue2 = townshipsAsDivisionMy[selectedValue1]![0];
          selectedValue3 = '';
          items2 = townshipsAsDivisionMy[selectedValue1]!;
          items3 = [];
        });
      },
      items: divisionMy.map((String item) {
        return DropdownMenuItem<String>(
          value: item,
          child: Text(item),
        );
      }).toList(),
    );
  }

  Widget buildDropdown2() {
    return DropdownButtonFormField<String>(
      value: selectedValue2,
      hint: const Text('မြို့နယ်ရွေးပါ'),
      onChanged: (String? value) {
        setState(() {
          selectedValue2 = value!;
          selectedValue3 = villagesAsTownshipMy[selectedValue2]![0];
          items3 = villagesAsTownshipMy[selectedValue2]!;
        });
      },
      items: items2.map((String item) {
        return DropdownMenuItem<String>(
          value: item,
          child: Text("$item မြို့နယ်"),
        );
      }).toList(),
    );
  }

  Widget buildDropdown3() {
    return DropdownButtonFormField<String>(
      value: selectedValue3,
      hint: const Text('ကျေးရွာ ရွေးချယ်ပါ'),
      onChanged: (String? value) {
        setState(() {
          selectedValue3 = value!;
        });
      },
      items: items3.map((String item) {
        return DropdownMenuItem<String>(
          value: item,
          child: Text("$item ကျေးရွာ"),
        );
      }).toList(),
    );
  }
}
10
likes
0
points
83
downloads

Publisher

verified publisheryannainglin.com

Weekly Downloads

Myanmar Administrative Areas, myanmar villages, myanmar townships, myanmar district, myanmar towns

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on myanmar_administrative_areas