搜索插件、代码仓与 APP 分类

country_flags 封面
插件详情v4.1.2

country_flags

一个 Flutter 包,用于从 ISO 国家代码显示国旗图标。

AndroidiOSmacOSWindowsLinux
近 30 天下载
21.7万
喜欢数
177
Pub 分数
160

安装插件

flutter pub add country_flags

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

country_flags 包是 Flutter 的一个实用工具,使开发者能够轻松地使用 ISO 国家代码显示国旗图标。它提供了一种简单高效的方法,将特定国家的旗帜集成到应用程序中,通过视觉上下文提升用户体验。该包支持 Android、iOS、macOS、Windows 和 Linux 等多个平台,确保在各种设备上的一致性渲染。通过 pub add 命令进行最少设置,即可无缝集成到现有的 Flutter 项目中。适用于涉及国际化、用户位置或区域选择的应用程序。

适合场景

  • 在个人资料中显示用户国家
  • 显示应用中的区域可用性
  • 增强多语言界面
  • 可视化位置数据
  • 表单中的国家选择支持
  • 在旅行或社交应用中集成旗帜

主要特点

  • 简单 ISO 代码输入
  • 跨平台兼容性
  • 轻量且快速
  • 预定义标志资产
  • 与 pubspec.yaml 的轻松集成
  • 一致的图标样式

适合对象

  • 国际化应用
  • 用户资料功能
  • 旅行和地图应用
  • 多语言平台
  • 基于位置的服务
  • 需要国家可视化界面

使用建议

  • 需要有效的 ISO 国家代码
  • 限于预定义的标志集
  • 不支持自定义标志
  • 可能会略微增加应用大小
  • 依赖外部资源仓库
  • 不适用于非国家旗帜

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Country Flags

Pub GitHub Workflow Status (with branch) Pull Requests are welcome codecov Null safety

A Flutter package for displaying the SVG image or the emoji of a country's flag.

The flag can be generated using:

View the complete list of supported countries here.

For a list of supported languages, visit www.lingoes.net/en/translator/langcode.htm (please note that not all language codes on the list are supported).

Showcase

Image flags

Image flags

Emoji flags

Emoji flags

Installation

Simply add country_flags to your pubspec.yaml file.

dependencies:
  country_flags: ^4.0.0

Usage

Create a flag using a country code.

fromCountryCode supports 2 and 3 letter country code

CountryFlag.fromCountryCode('ES');

or

CountryFlag.fromCountryCode('ESP');
Create a flag from a language code
CountryFlag.fromLanguageCode('en');
Create a flag from a Currency code
CountryFlag.fromCurrencyCode('USD');
Create a flag from a phone prefix
CountryFlag.fromPhonePrefix('+34');
Tweak the size of the flag
CountryFlag.fromLanguageCode(
  'en',
  theme: const ImageTheme(
    width: 120,
    height: 80,
  ),
);
Create a circular flag
CountryFlag.fromCountryCode(
  'ES',
  theme: const ImageTheme(
    shape: Circle(),
  ),
);
Create a rectangular flag with rounded corners
CountryFlag.fromCountryCode(
  'ES',
  theme: const ImageTheme(
    shape: RoundedRectangle(6),
  ),
);
Use the emoji theme
CountryFlag.fromCountryCode(
  'ES',
  theme: EmojiTheme(size: 60),
)

Credits

Special thanks to jovial_svg which is utilized to render the SVG images from binary files. Many thanks to bgoncharuck for the implementation.

Acknowledgments to the flag-icons project for providing the necessary SVG flags.

Alternatives

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

所在榜单