flutter_country_state 0.1.3+5

  • Readme
  • Changelog
  • Example
  • Installing
  • 62

flutter_country_state #

A package for Flutter with a heart of gold. A customizable Flutter package that displays all countries with there respective state.

show some ❤️ and star the repo to support the project. #

Example #

Please run the app in the Example folder

Installation #

dependencies:
  flutter:
    sdk: flutter
  flutter_country_state:

You can also change the style of the text of list of the country and states #

Use It #

This will display the countries #

 import 'package:flutter/material.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter_country_state/flutter_country_state.dart';

 class ShowCountry extends StatelessWidget {


   @override
   Widget build(BuildContext context) {
     return   GestureDetector(
                              child:Padding(
                                padding: EdgeInsets.symmetric(horizontal:20),
                                child: Align(
                                  alignment: Alignment.topLeft,
                                  child:  Column(
                                    children: <Widget>[
                                      Text('select country',

                                      ),
                                      Text(Variables.country,

                                      )
                                    ],
                                  ),


                                ),
                              ),
                              onTap: () {
                                showDialog(
                                    context: context,
                                    child: SimpleDialog(
                                      shape: RoundedRectangleBorder(
                                          borderRadius: BorderRadius.circular(8.0)),
                                      elevation: 4,
                                      children: <Widget>[

                                        Align(
                                          alignment: Alignment.topRight,
                                          child: GestureDetector(
                                              onTap: (){
                                                Navigator.of(context).push
                                                  (MaterialPageRoute(builder: (context) => YourClassName()));

                                              },
                                              child: Padding(
                                                padding: EdgeInsets.only(right:18.0),
                                                child: Material(
                                                  color:Colors.red,
                                                  child: Text('Done',

                                                  ),
                                                ),
                                              )
                                          ),
                                        ),
                                        SingleChildScrollView(
                                            child: Container(child: ShowMyDialog(
                                              searchHint: 'Search country',
                                              substringBackground: Colors.green,
                                            ))

                                        )
                                      ],

                                    )
                                );
                              }
                          ),

   }
 }

This will display the states of the country selected #

import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_country_state/flutter_country_state.dart';
class ShowState extends StatefulWidget {

  @override
  _ShowStateState createState() => _ShowStateState();
}

class _ShowStateState extends State<ShowState> {
  @override
  Widget build(BuildContext context) {
    return  GestureDetector(
                              child:Padding(
                                padding: EdgeInsets.symmetric(horizontal:20),
                                child: Align(
                                    alignment: Alignment.topLeft,
                                    child: Column(
                                      children: <Widget>[
                                        Text( 'select state',
                                        ),
                                        Text( Variables.state,
                                        ),
                                      ],
                                    )

                                ),
                              ),
                              onTap: (){
                                showDialog(
                                    context: context,
                                    child: SimpleDialog(
                                      shape: RoundedRectangleBorder(
                                          borderRadius: BorderRadius.circular(8.0)),
                                      elevation: 4,
                                      children: <Widget>[
                                        Align(
                                          alignment: Alignment.topRight,
                                          child: GestureDetector(
                                              onTap: (){
                                                Navigator.of(context).push
                                                  (MaterialPageRoute(builder: (context) => YourClassName()));

                                              },
                                              child: Padding(
                                                padding: EdgeInsets.only(right:18.0),
                                                child: Material(
                                                  color:Colors.red,
                                                  child: Text('Done',

                                                  ),
                                                ),
                                              )
                                          ),
                                        ),

                                        SingleChildScrollView(child: Container(child:StateDialog(),),)

                                      ],

                                    )
                                );

                              }
                          ),

  }
}

Check this #

Happy Coding!!!

[0.1.3+5] - 2020-31-03 #

  • A customizable Flutter package that displays a country with its respective state.

example/main.dart

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


void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'flutter_country_states page',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'flutter_country_states page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: SingleChildScrollView(
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              //ToDo: first import the package

              GestureDetector(
                  child:Padding(
                    padding: EdgeInsets.symmetric(horizontal:20),
                    child: Align(
                      alignment: Alignment.topLeft,
                      child:  Column(
                        children: <Widget>[
                          Text('select country',

                          ),
                          Text(Variables.country,

                          )
                        ],
                      ),


                    ),
                  ),
                  onTap: () {
                    showDialog(
                        context: context,
                        child: SimpleDialog(
                          shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(8.0)),
                          elevation: 4,
                          children: <Widget>[

                            Align(
                              alignment: Alignment.topRight,
                              child: GestureDetector(
                                  onTap: (){
                                    Navigator.of(context).push
                                      (MaterialPageRoute(builder: (context) => YourClassName()));

                                  },
                                  child: Padding(
                                    padding: EdgeInsets.only(right:18.0),
                                    child: Material(
                                      color:Colors.red,
                                      child: Text('Done',

                                      ),
                                    ),
                                  )
                              ),
                            ),
                            SingleChildScrollView(
                                child: Container(child: ShowMyDialog(
                                  searchHint: 'Search country',
                                  substringBackground: Colors.green,
                                ))

                            )
                          ],

                        )
                    );
                  }
              ),

              /*for states selected*/

              GestureDetector(
                  child:Padding(
                    padding: EdgeInsets.symmetric(horizontal:20),
                    child: Align(
                        alignment: Alignment.topLeft,
                        child: Column(
                          children: <Widget>[
                            Text( 'select state',
                            ),
                            Text( Variables.state,
                            ),
                          ],
                        )

                    ),
                  ),
                  onTap: (){
                    showDialog(
                        context: context,
                        child: SimpleDialog(
                          shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(8.0)),
                          elevation: 4,
                          children: <Widget>[
                            Align(
                              alignment: Alignment.topRight,
                              child: GestureDetector(
                                  onTap: (){
                                    Navigator.of(context).push
                                      (MaterialPageRoute(builder: (context) => YourClassName()));

                                  },
                                  child: Padding(
                                    padding: EdgeInsets.only(right:18.0),
                                    child: Material(
                                      color:Colors.red,
                                      child: Text('Done',

                                      ),
                                    ),
                                  )
                              ),
                            ),

                            SingleChildScrollView(child: Container(child:StateDialog(),),)

                          ],

                        )
                    );

                  }
              ),

            ],
          ),
        ),
      ),

    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_country_state: ^0.1.3+5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_country_state/flutter_country_state.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
39
Health:
Code health derived from static analysis. [more]
74
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • flutter_country_state that is a package requiring null.

Health issues and suggestions

Document public APIs. (-0.84 points)

953 out of 958 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/state-list.dart. (-25 points)

Analysis of lib/state-list.dart reported 225 hints, including:

line 11 col 23: Name non-constant identifiers using lowerCamelCase.

line 16 col 23: Name non-constant identifiers using lowerCamelCase.

line 21 col 23: Name non-constant identifiers using lowerCamelCase.

line 28 col 23: Name non-constant identifiers using lowerCamelCase.

line 33 col 23: Name non-constant identifiers using lowerCamelCase.

Fix lib/cty-list.dart. (-0.50 points)

Analysis of lib/cty-list.dart reported 1 hint:

line 4 col 23: Name non-constant identifiers using lowerCamelCase.

Fix lib/flutter_country_state.dart. (-0.50 points)

Analysis of lib/flutter_country_state.dart reported 1 hint:

line 41 col 14: This method overrides a method annotated as '@mustCallSuper' in 'State', but doesn't invoke the overridden method.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test