搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

所在榜單