currency_country_picker 1.0.0
currency_country_picker: ^1.0.0 copied to clipboard
A flutter package to select country with phone code and currency.
example/lib/main.dart
import 'package:currency_country_picker/currency_country_picker.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const App());
}
class App extends StatefulWidget {
const App({super.key});
@override
State<App> createState() => _AppState();
}
class _AppState extends State<App> {
@override
Widget build(BuildContext context) {
return MaterialApp(
themeMode: ThemeMode.dark,
theme: ThemeData.dark(),
debugShowCheckedModeBanner: false,
home: const HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
String countryTitle = 'Country';
String currencyTitle = 'Currency';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Country Picker'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Text('Country Picker:'),
ElevatedButton(
onPressed: () => showCountryPicker(
context: context,
onSelect: (country) {
setState(() {
countryTitle = country.name;
});
},
),
child: Text(countryTitle),
),
const SizedBox(height: 50),
const Text('Currency Picker:'),
ElevatedButton(
onPressed: () => showCurrencyPicker(
context: context,
onSelect: (currency) {
setState(() {
currencyTitle = currency.currencyName;
});
},
),
child: Text(currencyTitle),
),
],
),
));
}
}