flutter_country_state 0.1.3+2
flutter_country_state: ^0.1.3+2 copied to clipboard
A customizable Flutter package that displays all countries with there 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:Variables.country == null? Text('select country'):Text(Variables.country),
onTap: (){
showGeneralDialog(
barrierColor: Colors.black.withOpacity(0.5),
transitionBuilder: (context, a1, a2, widget) {
return Transform.scale(
scale: a1.value,
child: Opacity(
opacity: a1.value,
child: Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0)),
elevation: 4,
child: SingleChildScrollView(
child:
Container(child:ShowMyDialog())
)
)
)
);
},
transitionDuration: Duration(milliseconds: 200),
barrierDismissible: true,
barrierLabel: '',
context: context,
// ignore: missing_return
pageBuilder: (context, animation1, animation2) {}
);
}
),
/*for states selected*/
GestureDetector(
child:Variables.state == null? Text('select state'):Text(Variables.state),
onTap: (){
showGeneralDialog(
barrierColor: Colors.black.withOpacity(0.5),
transitionBuilder: (context, a1, a2, widget) {
return Transform.scale(
scale: a1.value,
child: Opacity(
opacity: a1.value,
child: Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0)),
elevation: 4,
child: Column(
children: <Widget>[
SingleChildScrollView(child: Container(child:StateDialog(),),)
]
)
)
)
);
},
transitionDuration: Duration(milliseconds: 200),
barrierDismissible: true,
barrierLabel: '',
context: context,
// ignore: missing_return
pageBuilder: (context, animation1, animation2) {}
);
},
),
],
),
),
),
);
}
}