Skip to content

Commit

Permalink
test: fully test world_flags (#206)
Browse files Browse the repository at this point in the history
* fix(lint): fix linter issues

* test: added golden tests for country flag class

* refactor(test): adjust anti-alias for tests

* test(ui): added more tests (i.e. for country flag custom constructor).

* test: improve code coverage to almost 100%

* refactor(ui): refactor ago painter

* docs: update docs and badges for v0.7.0

* chore(test): update goldens from linux machine

* fix(ci): remove flutter file
  • Loading branch information
tsinis authored Jul 28, 2024
1 parent 3bd4f96 commit cc052c0
Show file tree
Hide file tree
Showing 738 changed files with 559 additions and 216 deletions.
2 changes: 1 addition & 1 deletion .github/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![CodeFactor](https://www.codefactor.io/repository/github/tsinis/sealed_world/badge)](https://www.codefactor.io/repository/github/tsinis/sealed_world)
[![Codecov](https://codecov.io/github/tsinis/sealed_world/branch/main/graph/badge.svg)](https://app.codecov.io/github/tsinis/sealed_world/flags)
![Last commit](https://img.shields.io/github/last-commit/badges/shields/master)
![Last commit](https://img.shields.io/github/last-commit/tsinis/sealed_world)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Sealed World
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/world_flags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: verify_world_flags

on:
push:
branches: [main]
paths:
- "packages/world_flags/**/*.dart"
pull_request:
branches: [main]
paths:
- "packages/world_flags/**/*.dart"
- ".github/workflows/world_flags.yaml"

jobs:
verify-world-flags:
uses: ./.github/workflows/verify_package_workflow.yaml
with:
package_name: world_flags
is_flutter: true
secrets: inherit
46 changes: 46 additions & 0 deletions .vscode/sealed_world.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"Potencier",
"Saša",
"Stamenković",
"subdir",
"subtag",
"Symfony",
"taeguk",
Expand Down Expand Up @@ -411,6 +412,51 @@
"command": "cwebp -q 90 doc/example.png -o doc/example.webp",
"label": "Convert Example PNG to WEBP",
"presentation": { "revealProblems": "onProblem", "close": true }
},
{
"label": "Disable Font Smoothing on macOS",
"type": "shell",
"command": "defaults -currentHost write -g AppleFontSmoothing -int 0",
"presentation": { "reveal": "always" },
"problemMatcher": []
},
{
"label": "Update Goldens",
"type": "shell",
"command": "flutter test --update-goldens",
"presentation": { "reveal": "always" },
"problemMatcher": []
},
{
"label": "Enable Font Smoothing on macOS",
"type": "shell",
"command": "defaults -currentHost write -g AppleFontSmoothing -int 3",
"presentation": { "reveal": "always" },
"problemMatcher": []
},
{
"label": "Generate Goldens on macOS",
"type": "shell",
"dependsOrder": "sequence",
"dependsOn": [
"Disable Font Smoothing on macOS",
"Update Goldens",
"Enable Font Smoothing on macOS"
],
"presentation": { "reveal": "always" },
"problemMatcher": []
},
{
"label": "Run Golden Tests on macOS",
"type": "shell",
"dependsOrder": "sequence",
"dependsOn": [
"Disable Font Smoothing on macOS",
"Show Flutter Coverage",
"Enable Font Smoothing on macOS"
],
"presentation": { "reveal": "always" },
"problemMatcher": []
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion packages/sealed_countries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Codecov](https://codecov.io/github/tsinis/sealed_world/branch/main/graph/badge.svg)](https://app.codecov.io/github/tsinis/sealed_world/flags)
[![sealed_countries](https://github.com/tsinis/sealed_world/actions/workflows/sealed_countries.yaml/badge.svg)](https://github.com/tsinis/sealed_world/actions/workflows/sealed_countries.yaml)
![Pub points](https://img.shields.io/pub/points/sealed_countries)
![Last commit](https://img.shields.io/github/last-commit/badges/shields/master)
![Last commit](https://img.shields.io/github/last-commit/tsinis/sealed_world)
![Pub popularity](https://img.shields.io/pub/popularity/sealed_countries)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Pub package](https://img.shields.io/pub/v/sealed_countries.svg)](https://pub.dev/packages/sealed_countries)
Expand Down
2 changes: 1 addition & 1 deletion packages/sealed_currencies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Codecov](https://codecov.io/github/tsinis/sealed_world/branch/main/graph/badge.svg)](https://app.codecov.io/github/tsinis/sealed_world/flags)
[![sealed_currencies](https://github.com/tsinis/sealed_world/actions/workflows/sealed_currencies.yaml/badge.svg)](https://github.com/tsinis/sealed_world/actions/workflows/sealed_currencies.yaml)
![Pub points](https://img.shields.io/pub/points/sealed_currencies)
![Last commit](https://img.shields.io/github/last-commit/badges/shields/master)
![Last commit](https://img.shields.io/github/last-commit/tsinis/sealed_world)
![Pub popularity](https://img.shields.io/pub/popularity/sealed_currencies)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Pub package](https://img.shields.io/pub/v/sealed_currencies.svg)](https://pub.dev/packages/sealed_currencies)
Expand Down
2 changes: 1 addition & 1 deletion packages/sealed_languages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Codecov](https://codecov.io/github/tsinis/sealed_world/branch/main/graph/badge.svg)](https://app.codecov.io/github/tsinis/sealed_world/flags)
[![sealed_languages](https://github.com/tsinis/sealed_world/actions/workflows/sealed_languages.yaml/badge.svg)](https://github.com/tsinis/sealed_world/actions/workflows/sealed_languages.yaml)
![Pub points](https://img.shields.io/pub/points/sealed_languages)
![Last commit](https://img.shields.io/github/last-commit/badges/shields/master)
![Last commit](https://img.shields.io/github/last-commit/tsinis/sealed_world)
![Pub popularity](https://img.shields.io/pub/popularity/sealed_languages)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Pub package](https://img.shields.io/pub/v/sealed_languages.svg)](https://pub.dev/packages/sealed_languages)
Expand Down
4 changes: 2 additions & 2 deletions packages/world_countries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Codecov](https://codecov.io/github/tsinis/sealed_world/branch/main/graph/badge.svg)](https://app.codecov.io/github/tsinis/sealed_world/flags)
[![world_countries](https://github.com/tsinis/sealed_world/actions/workflows/world_countries.yaml/badge.svg)](https://github.com/tsinis/sealed_world/actions/workflows/world_countries.yaml)
![Pub points](https://img.shields.io/pub/points/world_countries)
![Last commit](https://img.shields.io/github/last-commit/badges/shields/master)
![Last commit](https://img.shields.io/github/last-commit/tsinis/sealed_world)
![Pub popularity](https://img.shields.io/pub/popularity/world_countries)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Pub package](https://img.shields.io/pub/v/world_countries.svg)](https://pub.dev/packages/world_countries)
Expand Down Expand Up @@ -286,6 +286,6 @@ CountryPicker(
- **No 3rd-party dependencies**: This package has no third-party dependencies, ensuring that you won't have any issues or conflicts with other dependencies (no even `meta` here, because of that).
- **Rich data**: This package offers far more data than any other package + tons of translations (all [GlobalMaterialLocalizations](https://api.flutter.dev/flutter/flutter_localizations/GlobalMaterialLocalizations-class.html) and [GlobalCupertinoLocalizations](https://api.flutter.dev/flutter/flutter_localizations/GlobalCupertinoLocalizations-class.html) locales and more).
- **Type-safe**: The contracts and types in this package are very strong, ensuring that your code is strongly typed and well-defined.
- **High code coverage**: The code in this package has almost 100% code coverage, with more than 130 (+3140 in underling Dart packages) tests, providing confidence in its reliability and stability.
- **High code coverage**: The code in this package has almost 100% code coverage, with more than 130 (+3819 in underling Dart packages) tests, providing confidence in its reliability and stability.
- **Industry adopted**: This package is actively used in production by numerous European companies, ensuring its efficacy and robustness in real-world scenarios.
- **MIT License**: This package and sources are released under the MIT license, which is a permissive license that allows users to use, modify, and distribute the code with minimal restrictions. The MIT license is considered better than most other open-source licenses because it provides flexibility and allows users to incorporate the code into their projects without worrying about legal implications.
48 changes: 28 additions & 20 deletions packages/world_countries/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ packages:
dependency: transitive
description:
name: build_daemon
sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1"
sha256: "79b2aef6ac2ed00046867ed354c88778c9c0f029df8a20fe10b5436826721ef9"
url: "https://pub.dev"
source: hosted
version: "4.0.1"
version: "4.0.2"
build_resolvers:
dependency: transitive
description:
Expand All @@ -109,10 +109,10 @@ packages:
dependency: transitive
description:
name: build_runner_core
sha256: "4ae8ffe5ac758da294ecf1802f2aff01558d8b1b00616aa7538ea9a8a5d50799"
sha256: e3c79f69a64bdfcd8a776a3c28db4eb6e3fb5356d013ae5eb2e52007706d5dbe
url: "https://pub.dev"
source: hosted
version: "7.3.0"
version: "7.3.1"
built_collection:
dependency: transitive
description:
Expand Down Expand Up @@ -313,10 +313,10 @@ packages:
dependency: transitive
description:
name: graphs
sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19
sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0"
url: "https://pub.dev"
source: hosted
version: "2.3.1"
version: "2.3.2"
hashcodes:
dependency: transitive
description:
Expand All @@ -337,10 +337,10 @@ packages:
dependency: transitive
description:
name: http
sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938"
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
url: "https://pub.dev"
source: hosted
version: "1.2.1"
version: "1.2.2"
http_multi_server:
dependency: transitive
description:
Expand Down Expand Up @@ -513,10 +513,10 @@ packages:
dependency: transitive
description:
name: platform
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
url: "https://pub.dev"
source: hosted
version: "3.1.4"
version: "3.1.5"
pool:
dependency: transitive
description:
Expand Down Expand Up @@ -553,10 +553,10 @@ packages:
dependency: transitive
description:
name: pubspec_parse
sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367
sha256: c799b721d79eb6ee6fa56f00c04b472dcd44a30d258fac2174a6ec57302678f8
url: "https://pub.dev"
source: hosted
version: "1.2.3"
version: "1.3.0"
quiver:
dependency: "direct main"
description:
Expand Down Expand Up @@ -609,10 +609,10 @@ packages:
dependency: transitive
description:
name: shelf_web_socket
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
version: "2.0.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -710,10 +710,10 @@ packages:
dependency: transitive
description:
name: uuid
sha256: "814e9e88f21a176ae1359149021870e87f7cddaf633ab678a5d2b0bff7fd1ba8"
sha256: "83d37c7ad7aaf9aa8e275490669535c8080377cfa7a7004c24dfac53afffaa90"
url: "https://pub.dev"
source: hosted
version: "4.4.0"
version: "4.4.2"
vector_graphics_codec:
dependency: transitive
description:
Expand Down Expand Up @@ -758,18 +758,26 @@ packages:
dependency: transitive
description:
name: web
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062
url: "https://pub.dev"
source: hosted
version: "0.5.1"
version: "1.0.0"
web_socket:
dependency: transitive
description:
name: web_socket
sha256: "3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83"
url: "https://pub.dev"
source: hosted
version: "0.1.6"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: "58c6666b342a38816b2e7e50ed0f1e261959630becd4c879c4f26bfa14aa5a42"
sha256: "9f187088ed104edd8662ca07af4b124465893caf063ba29758f97af57e61da8f"
url: "https://pub.dev"
source: hosted
version: "2.4.5"
version: "3.0.1"
world_countries:
dependency: "direct main"
description:
Expand Down
7 changes: 7 additions & 0 deletions packages/world_flags/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.7.0

TESTS

- Added unit, widget and golden tests for the package with code coverage around 100%.
- Small refactoring related to the linter rules.

## 0.6.0

NEW FEATURES
Expand Down
23 changes: 21 additions & 2 deletions packages/world_flags/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
[![CodeFactor](https://www.codefactor.io/repository/github/tsinis/sealed_world/badge)](https://www.codefactor.io/repository/github/tsinis/sealed_world)
[![Codecov](https://codecov.io/github/tsinis/sealed_world/branch/main/graph/badge.svg)](https://app.codecov.io/github/tsinis/sealed_world/flags)
[![world_flags](https://github.com/tsinis/sealed_world/actions/workflows/world_flags.yaml/badge.svg)](https://github.com/tsinis/sealed_world/actions/workflows/world_flags.yaml)
![Pub points](https://img.shields.io/pub/points/world_flags)
![Last commit](https://img.shields.io/github/last-commit/tsinis/sealed_world)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Pub package](https://img.shields.io/pub/v/world_flags.svg)](https://pub.dev/packages/world_flags)

# Every country flag is a Widget

Flutter library for compact and visually appealing country flag icons. Optimized for rendering sizes from 18 to 48 pixels (height), these flags draw inspiration from circle-flags, OpenMoji, and Twemoji. Over two-thirds of the flags in this library are also suitable for full-scale use.

Each flag is a vector-based CustomPainter, ensuring precise, scalable, and stunning results at any size. By following official color standards and using a declarative design, world_flags allows easy customization of flag shapes, decorations and aspect ratios without losing quality.
Each flag is a vector-based CustomPainter, ensuring precise, scalable, and stunning results. By following official color standards and using a declarative design, world_flags allows easy customization of flag shapes, decorations and aspect ratios without losing quality or breaking flag element proportions.

![Example](https://raw.githubusercontent.com/tsinis/sealed_world/main/packages/world_flags/doc/example.gif)

Expand All @@ -30,7 +35,7 @@ dependencies:
### Usage
All you need is a [WorldCountry](https://github.com/tsinis/sealed_world/tree/main/packages/sealed_countries#usage) instance (either create with factories of that class or just pick some specific one, i.e. `CountryDeu()`). Use it in the `CountryFlag` widget. For example:
All you need is a [WorldCountry](https://github.com/tsinis/sealed_world/tree/main/packages/sealed_countries#usage) instance (either create with factories of that class or just pick some specific one, i.e. `const CountryDeu()`). Use it in the `CountryFlag` widget. For example:

```dart
import "package:flutter/material.dart";
Expand Down Expand Up @@ -116,3 +121,17 @@ If you have any issues or suggestions for the package, please file them in the G
### References and credits

This package is licensed under the MIT license. See [LICENSE](./LICENSE) for details. This package dependencies are under their respective licenses (that can be found in their respective folders under LICENSE and NOTICE files).

### FAQ

#### Why should I use this package over any other country flag package?

- **Every flag is a Widget** - This package doesn't use heavy SVG or any other assets, all flags are declarative-style optimized CustomPainters. That means that you don't have to worry about pre-caching, increased app size, platform dependant look of the flags, etc. And since it's a widget - you can always change it's look - shape, decoration, aspect ratio, etc. Just ask yourself for example - how you can easily change aspect ratio of asset based flags without stretching/shrinking them?
- **Custom flags** - package provides multiple classes and simple API to create your own flags.
- **Sealed classes**: This package provides data in the form of sealed classes, allowing you to create your own instances and work with them as with existing ones (for example this is not possible with enums or regular classes (without losing it's sealed nature), you can also override existing or add new data, etc.).
- **No 3rd-party dependencies**: This package has no third-party dependencies, ensuring that you won't have any issues or conflicts with other dependencies (no even `meta` here, because of that).
- **Rich data**: This package offers far more data than any other package + tons of translations (all [GlobalMaterialLocalizations](https://api.flutter.dev/flutter/flutter_localizations/GlobalMaterialLocalizations-class.html) and [GlobalCupertinoLocalizations](https://api.flutter.dev/flutter/flutter_localizations/GlobalCupertinoLocalizations-class.html) locales and more).
- **Type-safe**: The contracts and types in this package are very strong, ensuring that your code is strongly typed and well-defined.
- **High code coverage**: The code in this package has almost 100% code coverage, with more than 678 (+3140 in underling Dart packages) tests, providing confidence in its reliability and stability.
- **Industry adopted**: This package is actively used in production by numerous European companies, ensuring its efficacy and robustness in real-world scenarios.
- **MIT License**: This package and sources are released under the MIT license, which is a permissive license that allows users to use, modify, and distribute the code with minimal restrictions. The MIT license is considered better than most other open-source licenses because it provides flexibility and allows users to incorporate the code into their projects without worrying about legal implications.
2 changes: 1 addition & 1 deletion packages/world_flags/example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ include: ../../flutter_analysis_options.yaml

linter:
rules:
public_member_api_docs: false
public_member_api_docs: false
2 changes: 1 addition & 1 deletion packages/world_flags/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.6.0"
version: "0.7.0"
sdks:
dart: ">=3.4.4 <4.0.0"
flutter: ">=3.22.3"
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,6 @@ const flagBrnProperties = FlagProperties(
ElementsProperties(
Color(0xffcf1126),
shape: Moon(radius: 0.95, offset: Offset(0, -0.45)),
offset: Offset(0, 0),
heightFactor: 0.5,
),
],
Expand Down
5 changes: 1 addition & 4 deletions packages/world_flags/lib/src/data/flags_map_part_2.data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1027,13 +1027,11 @@ const flagMneProperties = FlagProperties(
Color(0xffd3ae3b),
shape: Rectangle(aspectRatio: 0.05),
offset: Offset(-1, 0),
heightFactor: 1,
),
ElementsProperties(
Color(0xffd3ae3b),
shape: Rectangle(aspectRatio: 0.05),
offset: Offset(1, 0),
heightFactor: 1,
),
],
url: "https://www.vexilla-mundi.com/montenegro/montenegro_sheet.png",
Expand Down Expand Up @@ -1598,7 +1596,6 @@ const flagNplProperties = FlagProperties(
Color(0xffffffff),
shape: Star(points: 16, radiusFactor: 0.7),
offset: Offset(0, 0.04),
heightFactor: 1,
),
),
],
Expand Down Expand Up @@ -2168,7 +2165,7 @@ const flagMngProperties = FlagProperties(
heightFactor: 1.6,
child: ElementsProperties(
Color(0xffffd900),
shape: Moon(radius: 1.0, offset: Offset(0, -0.3)),
shape: Moon(radius: 1, offset: Offset(0, -0.3)),
offset: Offset(0, 0.4),
heightFactor: 1.4,
child: ElementsProperties(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2270,7 +2270,6 @@ const flagMltProperties = FlagProperties(
Color.fromARGB(0, 255, 255, 255),
shape: Rectangle(aspectRatio: 1),
offset: Offset(-0.915, -0.86),
heightFactor: 1,
child: ElementsProperties(
Color(0xffCF142B),
shape: Rectangle(aspectRatio: 0.3),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:flutter/rendering.dart';
import "package:flutter/rendering.dart";

abstract interface class DecoratedFlagInterface {
const DecoratedFlagInterface( // coverage:ignore-line
Expand Down
Loading

0 comments on commit cc052c0

Please sign in to comment.