circle_flags

7.0.0

A collection of round flags

Download archive

Readme

circle_flags

A collection of circular country flags.

Demo

to view all flags https://hatscripts.github.io/circle-flags/gallery

Usage


// use a valid country code
CircleFlag('us');
CircleFlag('fr');
CircleFlag(Flag.US);

Preloading

You might want to preload images for a smoother list scrolling experience:

CircleFlag.preload(['fr', 'us']);

// or await it to know when the flags are ready to be painted
await CircleFlag.preload(Flag.values);

Flags are read from the DefaultAssetBundle of the given context, or from rootBundle when there is none. To preload from a bundle of your own, pass it:

await CircleFlag.preload(['fr', 'us'], assetBundle: myAssetBundle);

Iso codes are case insensitive, 'us', 'US' and Flag.US all show the same flag.

Overwriting or adding custom flags

Some users have expressed their need to change some flags due to political reasons, or stylistic reasons. You might also wish to add your own flags. To do so refer to this issue: https://github.com/cedvdb/phone_form_field/issues/222

Contributing & issues

Bugs and feature requests go to https://github.com/cedvdb/flutter_circle_flags/issues, see CONTRIBUTING.md for how to set up the project, run the checks and release.

Flags live in assets/svg/, one <code>.svg file per flag; that directory is the source of truth and lib/src/flag.dart is generated from it. Never edit lib/src/flag.dart by hand, instead add or change the asset and run:

dart run tool/generate_flag.dart
Changelog

[7.0.0]

  • [Breaking] removed the public CircleFlag.cache field, preloading goes through CircleFlag.preload instead. CircleFlag.preload is now typed Future<void> (it was untyped) and accepts an optional context/assetBundle to preload from another asset bundle
  • iso codes are now case insensitive, CircleFlag('US') shows the same flag as CircleFlag('us') and CircleFlag.preload(['US']) preloads that same flag
  • added excludeFromSemantics and semanticsLabel options
  • the "?" fallback of unknown flags no longer relies on Future.catchError, which never completes inside the fake async zone of widget tests
  • a flag is cached under a package namespaced svg cache key, so the decoded flag can not collide with the svg cache key of another loader
  • added analysis_options.yaml and extended the test suite
  • moved the flag generator to tool/generate_flag.dart (pub layout convention)
  • the flag generator now refuses flag file names that can not be exposed as a Flag constant, see CONTRIBUTING.md
  • added CONTRIBUTING.md, it documents how flags are added and regenerated
  • the assets/svg_hatscripts working copy is no longer published, see assets/.pubignore
  • removed the unused build_runner dev dependency

[6.0.0]

  • upgrade to material_ui

[5.0.1]

  • Fix for build runner issue

[5.0.0]

  • Use latest files from hatscripts
  • Remove unnecessary files
  • Add note in readme on how to add your own flags
  • [Breaking] renamed Flags in Flag

[4.0.2]

  • Exclude from semantics

[4.0.1]

  • Accept iterable in preloading method

[4.0.0]

  • [Breaking] Use CircleFlag.preload([isoCode]) to preload a flag. FlagCache is no longer exported.

[3.0.1]

  • made it easier to use cache, some breaking changes to just introduced cache api (doesn't warrant upgrade due to it just being introduced)

[3.0.0]

  • unknown flags display "?"
  • revert to assets with preloading mechanism
  • allow usage of other asset bundles

[2.0.9]

  • recreate loader when iso code changes

[2.0.8]

  • Change just introduced caching api

[2.0.7]

  • Fix issue with network flags not correctly loaded
  • improve caching

[2.0.0]

  • use network image to reduce size
  • added ability to preload images

[1.0.4]

  • increase package:flutter_svg version
  • fix redering issue on some platforms

[1.0.3]

  • (Re)-added netherlands antilla's flag

[1.0.2]

  • add clipOval around flag for better rendering of svgs on the web

[1.0.1]

  • use sensible defaults for svgs placeholders

[1.0.0]

  • use svg for smaller memory footprint

[0.0.3]

  • added 3 missing flags

[0.0.2]

  • fix casing problems in country code

[0.0.1] - 22/03/2021

  • initial release

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add circle_flags
pubspec.yaml
name: circle_flags
description: A collection of round flags
version: 7.0.0
repository: https://github.com/cedvdb/flutter_circle_flags
issue_tracker: https://github.com/cedvdb/flutter_circle_flags/issues

topics:
  - flags
  - country-flags
  - svg

environment:
  sdk: ">=3.13.0 <4.0.0"
  flutter: ">=3.47.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_svg: ^2.3.0
  material_ui: ^1.4.0

dev_dependencies:
  flutter_lints: ^6.0.0
  flutter_test:
    sdk: flutter
  path: any

flutter:
  assets:
    - assets/svg/

Version history

VersionPublishedArchiveSHA-256
0.0.1On demandDownloadf99fb4f3…dd2b9f
0.0.2On demandDownload911bc175…13fe05
0.0.3On demandDownloadd83ec86d…f9c20d
1.0.0On demandDownload33298561…ab6824
1.0.1On demandDownload58713d68…7dca23
1.0.2On demandDownload4ac9eb7f…c49552
1.0.3On demandDownload96ab4c2c…c079f2
1.0.4On demandDownload87102c61…c95924
2.0.0On demandDownload9e4a2c62…4e3fc6
2.0.6On demandDownloadb941f84f…ed8f47
2.0.7On demandDownload547b252f…488a24
2.0.8On demandDownload6995cce5…68b7af
2.0.9On demandDownload793f94a7…798715
3.0.0On demandDownload90fe37fc…4f95e1
3.0.1On demandDownloadcac0fe72…b47ac4
4.0.0On demandDownloadbf798dd8…256611
4.0.1On demandDownload61bccd6a…55bbae
4.0.2On demandDownload028d5ca1…af2daa
5.0.0On demandDownload875cd64e…fb2f52
5.0.1On demandDownload22268452…34c181
6.0.0On demandDownload836bcf32…db4930
7.0.0Cached · Upstream SHA-256 matchedDownloadaa4adae6…d05b75

Dependencies

flutter { "sdk": "flutter" }

flutter_svg "^2.3.0"

material_ui "^1.4.0"