Skip to content

Flag icons in ImageVector format for Kotlin Multiplatform

License

Notifications You must be signed in to change notification settings

acarlsen/kmp-flagkit

Repository files navigation

GitHub Workflow Status (with event) Maven Central Kotlin version License: MIT badge badge badge badge badge badge

Flag icons in ImageVector format to use in Kotlin Multiplatform.

With heavy inspiration from the FlagKit and flagkit-android libraries.

Platform Support

  • Android
  • Desktop
  • iOS
  • MacOS Native
  • Web (JSCanvas)
  • WebAssembly (Wasm)

To use in your project

Add the repository:

repositories {
    mavenCentral()
}

Put in your dependencies block:

implementation("dev.carlsen.flagkit:flagkit:1.1.0")

How to use

Country flags can be referenced by the Alpha-2 code for each country.

There are also a few other flags available.

Country/state Code
England GB-ENG
Northern Ireland GB-NIR
Scotland GB-SCT
Wales GB-WLS
Shetland GB-ZET
California US-CA

Use Flag directly

Image(
    imageVector = FlagIcons.DK,
    contentDescription = "Denmark",
)

Lookup flag by country code

Image(
    imageVector = FlagKit.getFlag(countryCode = "DK"),
    contentDescription = "Denmark",
)