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

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 MaterialApp(
    debugShowCheckedModeBanner: false,
    home: MainApp(),
  ));
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("အသုံးပြုပုံ"),
        backgroundColor: ThemeData.light().primaryColor,
        foregroundColor: Colors.white,
      ),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(64.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Row(
                children: [
                  Expanded(
                      child: FilledButton(
                          onPressed: () => Navigator.of(context)
                              .push(_createPageRoute(const VillageExample())),
                          child: const Text("ကျေးရွာ နမူနာ")))
                ],
              ),
              const SizedBox(
                height: 16.0,
              ),
              Row(
                children: [
                  Expanded(
                    child: FilledButton(
                        onPressed: () => Navigator.of(context)
                            .push(_createPageRoute(const WardExample())),
                        child: const Text("ရပ်ကွက် နမူနာ")),
                  ),
                ],
              )
            ],
          ),
        ),
      ),
    );
  }

  PageRouteBuilder _createPageRoute(Widget page) {
    return PageRouteBuilder(
      pageBuilder: (context, animation, secondaryAnimation) => page,
      transitionsBuilder: (context, animation, secondaryAnimation, child) {
        const begin = Offset(1.0, 0.0);
        const end = Offset.zero;
        const curve = Curves.easeInOut;

        var tween =
            Tween(begin: begin, end: end).chain(CurveTween(curve: curve));

        var offsetAnimation = animation.drive(tween);

        return SlideTransition(
          position: offsetAnimation,
          child: child,
        );
      },
    );
  }
}

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

  @override
  State<VillageExample> createState() => _VillageExampleState();
}

class _VillageExampleState extends State<VillageExample> {
  String? selectedValue1;
  String? selectedValue2;
  String? selectedValue3;

  List<String> items2 = [];
  List<String> items3 = [];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('ကျေးရွာ နမူနာ'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(32.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            buildDropdown1(),
            const SizedBox(height: 16),
            items2.isNotEmpty ? buildDropdown2() : Container(),
            const SizedBox(height: 16),
            items3.isNotEmpty ? buildDropdown3() : Container(),
            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;
          selectedValue3 = null;
          selectedValue2 = null;
          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 = null;
          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(),
    );
  }
}

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

  @override
  State<WardExample> createState() => _WardExampleState();
}

class _WardExampleState extends State<WardExample> {
  String? selectedValue1;
  String? selectedValue2;
  String? selectedValue3;
  String? selectedValue4;

  List<String> items2 = [];
  List<String> items3 = [];
  List<String> items4 = [];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('ရပ်ကွက် နမူနာ'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(32.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            buildDropdown1(),
            const SizedBox(height: 16),
            items2.isNotEmpty ? buildDropdown2() : Container(),
            const SizedBox(height: 16),
            items3.isNotEmpty ? buildDropdown3() : Container(),
            const SizedBox(height: 16),
            items4.isNotEmpty ? buildDropdown4() : Container(),
            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 မြို့ \n $selectedValue4 ရပ်ကွက်",
                    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;
          items2 = townshipsAsDivisionMy[selectedValue1] ?? [];
          items3 = [];
          items4 = [];
          selectedValue2 = null;
          selectedValue3 = null;
          selectedValue4 = null;
        });
      },
      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 = null;
          items3 = townsAsTownshipMy[selectedValue2] ?? [];
        });
      },
      items: items2.isNotEmpty
          ? items2.map((String item) {
              return DropdownMenuItem<String>(
                value: item,
                child: Text("$item မြို့နယ်"),
              );
            }).toList()
          : [''].map((e) {
              return const DropdownMenuItem<String>(
                value: '',
                child: Text(''),
              );
            }).toList(),
    );
  }

  Widget buildDropdown3() {
    return DropdownButtonFormField<String>(
      value: selectedValue3,
      hint: const Text('မြို့ရွေးပါ'),
      onChanged: (String? value) {
        setState(() {
          selectedValue3 = value;
          selectedValue4 = null;
          items4 = wardsMy[selectedValue3] ?? [];
        });
      },
      items: items3.isNotEmpty
          ? items3.map((String item) {
              return DropdownMenuItem<String>(
                value: item,
                child: Text("$item မြို့"),
              );
            }).toList()
          : [''].map((e) {
              return const DropdownMenuItem<String>(
                value: '',
                child: Text(''),
              );
            }).toList(),
    );
  }

  Widget buildDropdown4() {
    return DropdownButtonFormField<String>(
      value: selectedValue4,
      hint: const Text('ရပ်ကွက်ရွေးပါ'),
      onChanged: (String? value) {
        setState(() {
          selectedValue4 = value!;
        });
      },
      items: items4.isNotEmpty
          ? items4.map((String item) {
              return DropdownMenuItem<String>(
                value: item,
                child: Text("$item ရပ်ကွက်"),
              );
            }).toList()
          : [''].map((e) {
              return const DropdownMenuItem<String>(
                value: '',
                child: Text(''),
              );
            }).toList(),
    );
  }
}
10
likes
0
pub points
20%
popularity

Publisher

verified publishermmandroidhack.com

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