country_flag_widget 0.0.3 country_flag_widget: ^0.0.3 copied to clipboard
A Flutter package to display country flags based on country names.
import 'package:flutter/material.dart';
import 'package:country_flag_widget/country_flag_widget.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
// Fetch all country flags once when the app starts
CountryFlagManager().fetchAllCountryFlags();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Country Flag Example',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
appBar: AppBar(
title: const Text('Country Flag Example'),
),
body: const Center(
child: Column(
children: [
// Replace "Pakistan" with the desired country name
CountryFlagWidget(
countryName: 'Pakistan',
width: 200,
height: 120,
),
SizedBox(height: 20),
CountryFlagWidget(
countryName: 'India',
width: 200,
height: 120,
),
SizedBox(height: 20),
CountryFlagWidget(
countryName: 'United States',
width: 200,
height: 120,
),
// Add more flags as needed
],
),
),
),
);
}
}