### Run Flutter Project Commands Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/README.md Commands to fetch project dependencies and run the Flutter application. Assumes Flutter SDK is installed. ```shell flutter pub get flutter run ``` -------------------------------- ### Installation Target Setup (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/linux/CMakeLists.txt Configures the installation process by setting the default install prefix to a bundle directory within the build directory. It also ensures a clean bundle directory is created before installation by removing any existing contents. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Project Configuration and Build Setup (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/linux/CMakeLists.txt This snippet sets up the basic CMake project configuration, including the minimum required version, project name, executable name, and application ID. It also enforces modern CMake behaviors and configures the installation path for bundled libraries. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) set(BINARY_NAME "world_flags_example") set(APPLICATION_ID "com.example.world_flags_example") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Install Application Components with CMake Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/windows/CMakeLists.txt This CMake code outlines the installation process for the application and its associated files. It defines installation directories for runtime components, libraries, and assets. It ensures that the main executable, Flutter ICU data, libraries, bundled plugin libraries, and native assets are correctly installed to the specified locations based on the build configuration and components. ```cmake set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### CMake Installation Rules for Bundle Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/linux/CMakeLists.txt Sets up installation rules for creating a relocatable application bundle. It defines installation directories for data and libraries, installs the executable, ICU data, Flutter library, bundled plugin libraries, and native assets. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installing Application Bundle Components (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/linux/CMakeLists.txt Installs the main executable, ICU data file, Flutter library, bundled plugin libraries, and native assets into the application bundle. Specific destinations are set for data, libraries, and the main executable. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installing AOT Library (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/linux/CMakeLists.txt Conditionally installs the Ahead-Of-Time (AOT) compiled library to the bundle's library directory. This installation is performed only for non-Debug build configurations. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Installing Flutter Assets (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/linux/CMakeLists.txt Installs the Flutter assets directory into the application bundle's data directory. It first removes any existing assets to ensure a clean copy is installed. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### CMake Installation Rules for Flutter Application Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/windows/CMakeLists.txt Configures the installation of the application executable, ICU data, Flutter library, bundled plugin libraries, native assets, and Flutter assets. It ensures these files are placed correctly for the application to run. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### CMake Project and Version Setup Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/windows/CMakeLists.txt Initializes the CMake build system, specifying the minimum required version and the project name. It also sets the CXX language standard for the project. ```cmake cmake_minimum_required(VERSION 3.14) project(world_countries_example LANGUAGES CXX) ``` -------------------------------- ### Get currency information and translations in Dart Source: https://github.com/tsinis/sealed_world/blob/main/packages/sealed_currencies/README.md This example showcases various ways to interact with the FiatCurrency class. It covers accessing currency lists, finding currencies by code or name, retrieving translations for different locales, and printing detailed currency information. Dependencies include the sealed_currencies package. ```dart print(FiatCurrency.listExtended.length); // Prints: "169". final serbianDinar = FiatCurrency.fromCode("Rsd"); print(serbianDinar.name); // Prints: "Serbian Dinar". final maybeEuro = FiatCurrency.maybeFromValue( "Euro", where: (currency) => currency.namesNative.first, ); print(maybeEuro?.toString(short: false)); /* Prints: "FiatCurrency(code: \"EUR\", name: \"Euro\", decimalMark: \"c\", thousandsSeparator: \".\", symbol: r\"€\", htmlEntity: \"€\", codeNumeric: \"978\", namesNative: [\"Euro\"], priority: 2, smallestDenomination: 1, subunit: \"Cent\", subunitToUnit: 100, unitFirst: true,)". */ // Prints German translations of all available regular currencies. final germanNames = FiatCurrency.list.commonNamesMap( options: const LocaleMappingOptions(mainLocale: BasicLocale(LangDeu())), ); print( "Fully translated to German: ${germanNames.length == FiatCurrency.list.length}"", ); // Prints: "Fully translated to German: true". for (final deuTranslation in germanNames.entries) { print("German name of ${deuTranslation.key.name}: ${deuTranslation.value}"); } print( serbianDinar.maybeCommonNameFor(const BasicLocale(LangPol())), ); // Prints common Polish name of RSD: "dinar serbski". ``` -------------------------------- ### CMake Project Setup and Configuration Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/linux/CMakeLists.txt Defines the minimum CMake version, project name, executable name, and application ID. It also sets up modern CMake behaviors and specifies the runtime path for bundled libraries, essential for executable linking. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "example") set(APPLICATION_ID "com.example.example") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Implement Fuzzy Search in Pickers (Dart) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/README.md This code illustrates how to integrate fuzzy search functionality into a picker using the `onSearchResultsBuilder` parameter. It assumes the use of a fuzzy search package (like `fuzzy` or similar) and shows how to filter search results based on a query against the first value of ISO objects. The example requires importing a fuzzy search utility. ```dart onSearchResultsBuilder: (query, map) => query.isNotEmpty ? extractAllSorted( choices: map.entries.toList(growable: false), getter: (iso) => iso.value.first, // I.e. fuzzy search on ISO object L10N. query: query, cutoff: 50, ).map((result) => result.choice.key) : items, // Original items or `map.keys` etc. ``` -------------------------------- ### Flutter App Setup with Country Picker and Theming Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/README.md This Dart code sets up a basic Flutter application, including internationalization delegates and theme extensions for pickers. It demonstrates the initialization of a `CountryPicker` with disabled countries and defines a `MainPage` widget with a customizable search functionality and a floating action button for phone code selection. ```dart import "dart:async" show unawaited; import "package:flutter/material.dart"; import "package:flutter_localizations/flutter_localizations.dart"; import "package:world_countries/world_countries.dart"; void main() => runApp( MaterialApp( home: const MainPage(), theme: ThemeData( /// And also [CurrencyTileThemeData], [LanguageTileThemeData], [CountryTileThemeData]... extensions: const [ PickersThemeData(primary: true), // Specify global pickers theme. FlagThemeData( decoration: BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(4))), ), ], ), localizationsDelegates: const [ GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, TypedLocaleDelegate( // ! Don't forget to add this delegate too ! localeMapResolution: [ /// Just as an example, Brazil could be mapped to Euro Portuguese. LocaleEntry( Locale("pt", "BR"), TypedLocale(LangPor(), country: CountryPrt()), ), ], ), ], supportedLocales: [ for (final locale in kMaterialSupportedLanguages) Locale(locale), const Locale("pt", "PT"), const Locale("pt", "BR"), ], ), ); class MainPage extends StatefulWidget { const MainPage({ super.key, // Immutable compile-time constant constructors in every picker. this.basicPicker = const CountryPicker(disabled: [CountryAbw()]), }); final CountryPicker basicPicker; @override State createState() => _MainPageState(); } class _MainPageState extends State with SingleTickerProviderStateMixin { /// Highly customizable, for example use itemBuilder param. for custom tiles. late CountryPicker picker = widget.basicPicker.copyWith(onSelect: onSelect); void onSelect(WorldCountry newCountry) { debugPrint("New country selected: $newCountry"); setState( () => picker = picker.copyWith( // A copyWith methods in every picker. chosen: selectedCountry == newCountry ? const [] : [newCountry], ), ); } void onFabPressed({bool isLongPress = false}) { /// Or for example: [LanguagePicker], [CurrencyPicker]. final phonePicker = PhoneCodePicker.fromCountryPicker(picker); unawaited( isLongPress ? phonePicker.showInDialog(context) : phonePicker.showInModalBottomSheet(context), ); } void onAppBarSearchLongPressed() => unawaited(picker.showInSearch(context)); WorldCountry? get selectedCountry => picker.chosen?.firstOrNull; @override Widget build(BuildContext context) => Scaffold( appBar: AppBar( actions: [ SearchAnchor( isFullScreen: false, viewConstraints: const BoxConstraints(minWidth: 220, maxWidth: 320), builder: (_, controller) => GestureDetector( onLongPress: onAppBarSearchLongPressed, child: IconButton( onPressed: controller.openView, icon: const Icon(Icons.search), ), ), suggestionsBuilder: picker.searchSuggestions, ), ], ), body: Center( child: MaybeWidget( selectedCountry?.maybeCommonNameFor(BasicTypedLocale(LangEng())), Text.new, orElse: const Text( "Please select country by pressing on the search icon", ), ), ), floatingActionButton: GestureDetector( onLongPress: () => onFabPressed(isLongPress: true), child: FloatingActionButton( onPressed: onFabPressed, child: const Icon(Icons.search), ), ), ); } ``` -------------------------------- ### Representing Map Information Source: https://github.com/tsinis/sealed_world/blob/main/packages/sealed_countries/README.md Details how map information for a country is stored, including links or identifiers for different map services like Google Maps and OpenStreetMap. The example shows identifiers for both. ```text Maps(googleMaps: "hxd1BKxgpchStzQC6", openStreetMaps: "relation/62273") ``` -------------------------------- ### Representing Gini Coefficient Source: https://github.com/tsinis/sealed_world/blob/main/packages/sealed_countries/README.md Shows the format for the Gini coefficient, which measures income inequality. It includes the year the coefficient was recorded and the coefficient value itself. The example shows a Gini coefficient for 2017. ```text Gini(year: 2017, coefficient: 31.4) ``` -------------------------------- ### Representing Geographic Coordinates (LatLng) Source: https://github.com/tsinis/sealed_world/blob/main/packages/sealed_countries/README.md Illustrates how geographic coordinates for a country are represented. This typically involves latitude and longitude values. The example shows a LatLng object with specific coordinates. ```text LatLng(53, -8) ``` -------------------------------- ### Representing Regional Blocs Source: https://github.com/tsinis/sealed_world/blob/main/packages/sealed_countries/README.md Shows how regional blocs a country belongs to are represented. The example indicates membership in the EU bloc. ```text [BlocEU()] ``` -------------------------------- ### Import sealed_currencies package in Dart code Source: https://github.com/tsinis/sealed_world/blob/main/packages/sealed_currencies/README.md This snippet demonstrates how to import the sealed_currencies package into your Dart files to start using its features. It's a standard import statement. ```dart import 'package:sealed_currencies/sealed_currencies.dart'; ``` -------------------------------- ### Representing Capital City Information Source: https://github.com/tsinis/sealed_world/blob/main/packages/sealed_countries/README.md Details the structure for capital city information, including the capital's name and its geographic coordinates. The example shows Dublin as the capital with its LatLng. ```text CapitalInfo(capital: Capital("Dublin"), latLng: LatLng(53.32, -6.23)) ``` -------------------------------- ### Representing Car Information Source: https://github.com/tsinis/sealed_world/blob/main/packages/sealed_countries/README.md Illustrates the data structure for car-related information in a country, including the car sign and whether driving is on the right side of the road. The example shows 'IRL' as the sign and `false` for right-side driving. ```text Car(sign: "IRL", isRightSide: false) ``` -------------------------------- ### Representing Border Country Codes Source: https://github.com/tsinis/sealed_world/blob/main/packages/sealed_countries/README.md Shows the format for representing the FIFA codes of countries that share a border. This is presented as a list of strings. The example shows a list containing 'GBR'. ```text ["GBR"] ``` -------------------------------- ### Import l10n_countries Package in Dart Source: https://github.com/tsinis/sealed_world/blob/main/packages/l10n_countries/README.md After adding the dependency, import the necessary components of the l10n_countries package into your Dart files to start using its features for country name localization. ```dart import 'package:l10n_countries/l10n_countries.dart'; ``` -------------------------------- ### Representing Demonyms (People's Names) Source: https://github.com/tsinis/sealed_world/blob/main/packages/sealed_countries/README.md Demonstrates the structure for storing demonyms, which are the names for people from a country. It supports multiple languages and specifies male and female forms. The example shows Irish and French demonyms. ```text [Demonyms(language: LangEng(), female: "Irish", male: "Irish"), Demonyms(language: LangFra(), female: "Irlandaise", male: "Irlandais")] ``` -------------------------------- ### Dart: Accessing and Filtering Country Data Source: https://github.com/tsinis/sealed_world/blob/main/packages/sealed_countries/README.md Shows how to access the list of all countries, retrieve a specific country by its code, filter countries by continent, and get translated names for a specific locale. ```dart print(WorldCountry.list.length); // Prints: "250". final country = WorldCountry.fromCode("MEX"); print(country.name.common); // Prints: "Mexico". final europeanCountries = WorldCountry.list.where( (cnt) => cnt.continent is Europe, ); print(europeanCountries); // Prints a list of European countries. // Prints German translations of all available regular countries. final germanNames = WorldCountry.list.commonNamesMap( options: const LocaleMappingOptions( mainLocale: BasicTypedLocale(LangDeu()), ), ); print( "Fully translated to German: ${germanNames.length == WorldCountry.list.length}", ); // Prints: "Fully translated to German: true". for (final deuTranslation in germanNames.entries) { print("German name of ${deuTranslation.key.name}: ${deuTranslation.value}"); } ``` -------------------------------- ### Add l10n_currencies Dependency to pubspec.yaml Source: https://github.com/tsinis/sealed_world/blob/main/packages/l10n_currencies/README.md This snippet shows how to add the l10n_currencies package as a project dependency in your pubspec.yaml file. This is the first step to start using the package's features in your Dart or Flutter application. ```yaml dependencies: l10n_currencies: any ``` -------------------------------- ### Add world_flags Dependency to pubspec.yaml Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/README.md This snippet shows how to add the 'world_flags' package as a dependency in your Flutter project's pubspec.yaml file. This is the initial step to start using the flag widgets in your application. ```yaml dependencies: world_flags: any ``` -------------------------------- ### Format Translations with TypedLocaleDelegate (Dart) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/README.md This example shows how to enhance the `TypedLocaleDelegate` to format translations conditionally. Specifically, it capitalizes French currency names while leaving other translations unchanged. This involves providing a custom `l10nFormatter` function that checks the locale and the type of the localized item. ```dart TypedLocaleDelegate( l10nFormatter: (l10n, locale) => locale.language.isFra && l10n.key is FiatCurrency ? l10n.value.toUpperCase() // Format French currency names only. : l10n.value, // Don't change other translations. ) ``` -------------------------------- ### Add world_countries Dependency to pubspec.yaml Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/README.md This snippet shows how to add the world_countries package as a dependency in your Flutter project's pubspec.yaml file. Ensure you have a stable Flutter SDK installed. This is the primary step to begin using the package's features. ```yaml dependencies: world_countries: any ``` -------------------------------- ### Configure C++ Executable Build with CMake Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/linux/runner/CMakeLists.txt This snippet defines the main C++ executable for the project. It specifies the executable name, lists all necessary source files including generated ones, and applies standard build settings. It also adds preprocessor definitions for the application ID and links essential libraries such as 'flutter' and 'PkgConfig::GTK'. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) # Define the application target. To change its name, change BINARY_NAME in the # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer # work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # Add preprocessor definitions for the application ID. add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") # Add dependency libraries. Add any application-specific dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Apply Standard Build Settings (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/windows/runner/CMakeLists.txt Applies a predefined set of standard build settings to the application target. This simplifies the build configuration for typical applications and can be customized if different settings are required. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Link Libraries and Include Directories (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/windows/runner/CMakeLists.txt Specifies the libraries and include directories required for the application. It links against Flutter's core libraries (`flutter`, `flutter_wrapper_app`) and the Windows `dwmapi.lib`, also setting the source directory as an include directory. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Apply Standard Compilation Settings with CMake Function Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/windows/CMakeLists.txt This CMake function, APPLY_STANDARD_SETTINGS, is designed to apply common compilation features, options, and definitions to a target. It enforces C++17 standard, sets specific warning levels, disables unused parameter warnings, enables C++ exception handling, and defines the _DEBUG macro for Debug configurations. This promotes consistent build settings across different targets. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE '$<$:_DEBUG>') endfunction() ``` -------------------------------- ### Cross-Building System Root Configuration (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/linux/CMakeLists.txt This section configures the CMake toolchain for cross-building by setting the system root path and adjusting find modes for programs, packages, libraries, and includes based on the FLUTTER_TARGET_PLATFORM_SYSROOT variable. ```cmake if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() ``` -------------------------------- ### Flutter Integration and Dependencies (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/linux/CMakeLists.txt This snippet integrates Flutter build rules by adding the Flutter managed directory as a subdirectory and finding necessary system-level GTK libraries using PkgConfig. It also adds the runner subdirectory and ensures the main binary depends on the flutter_assemble target. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_subdirectory("runner") add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### CMake Executable Target Definition Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/linux/CMakeLists.txt Defines the main executable target for the application, listing its source files including main.cc, my_application.cc, and generated plugin registration code. It applies standard build settings and links necessary libraries like Flutter and GTK. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) apply_standard_settings(${BINARY_NAME}) target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Configure Flutter Tool Backend Command in CMake Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/windows/flutter/CMakeLists.txt This CMake snippet configures a custom command to invoke the Flutter tool backend. It defines a phony output to ensure the command runs every time, setting up environment variables and executing the `tool_backend.bat` script with platform and configuration arguments. This command generates necessary build outputs like the Flutter library and headers. ```cmake # _phony_ is a non-existent file to force this command to run every time, # since currently there's no way to get a full input/output list from the # flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" ${FLUTTER_TARGET_PLATFORM} $ VERBATIM ) ``` -------------------------------- ### Define Executable Target and Source Files (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/windows/runner/CMakeLists.txt Defines the main executable target for the application, listing all necessary source files. It includes standard Flutter-generated files and Windows-specific resources. This configuration is crucial for linking the application and ensuring `flutter run` functionality. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) ``` -------------------------------- ### CMake: Flutter tool backend custom command Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/linux/flutter/CMakeLists.txt Defines a custom command to execute the Flutter tool backend script. This command generates the Flutter library and header files. A dummy output file `_phony_` is used to ensure the command runs on every build, as direct input/output tracking for the tool backend is not fully implemented. ```cmake add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/_phony_ COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### CMake Flutter and GTK Integration Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/linux/CMakeLists.txt Includes Flutter's build directory and finds the GTK library using PkgConfig. It defines the APPLICATION_ID as a preprocessor macro for the application. This integrates Flutter's build system and GTK as a system dependency. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### CMake: Find GTK, GLIB, GIO dependencies Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/linux/flutter/CMakeLists.txt Uses PkgConfig to find and configure system-level dependencies for GTK, GLIB, and GIO. This ensures that the necessary header files and libraries are available for building the Flutter application. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) ``` -------------------------------- ### Build Flutter C++ Wrapper for Plugins in CMake Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/windows/flutter/CMakeLists.txt This CMake snippet constructs a static C++ wrapper library intended for Flutter plugins. It defines core implementation sources and plugin-specific sources, transforms their paths, and then adds them to a static library target named `flutter_wrapper_plugin`. It also configures independent code, visibility, public include directories, and dependencies. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/ ") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/ ") # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) ``` -------------------------------- ### Build Flutter C++ Wrapper for Runner in CMake Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/windows/flutter/CMakeLists.txt This CMake configuration creates a static C++ wrapper library for the Flutter runner application. It includes core implementation sources and application-specific sources, adds them to the `flutter_wrapper_app` static library target, and sets up public include directories and links against the Flutter library. It also ensures independent code generation and links against the main Flutter library. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/ ") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/ ") # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### Define Flutter Library Targets and Includes (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/windows/flutter/CMakeLists.txt This CMake snippet defines the Flutter library, its header files, and linking information. It sets up include directories and links against the Flutter library. Dependencies are managed by 'flutter_assemble'. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### CMake: Define Flutter library and headers Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/linux/flutter/CMakeLists.txt Sets the paths for the Flutter library (`libflutter_linux_gtk.so`) and its associated header files. It then creates an interface library target named `flutter` and configures its include directories and link libraries to include Flutter, GTK, GLIB, and GIO. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Standard Compilation Settings Function (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/linux/CMakeLists.txt Defines a CMake function `APPLY_STANDARD_SETTINGS` that applies common compilation features, warnings, optimization levels, and preprocessor definitions to a given target. It enables C++14 support, enforces Wall and Werror, applies O3 optimization for non-Debug builds, and defines NDEBUG for non-Debug configurations. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "<$>:NDEBUG>") endfunction() ``` -------------------------------- ### Configure Flutter C++ Wrapper for Runner (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/windows/flutter/CMakeLists.txt This CMake configuration sets up a static library for the Flutter C++ wrapper, intended for the runner (application). It includes core and application-specific implementation files, links against the Flutter library, and specifies include directories. Dependencies are managed by 'flutter_assemble'. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### Dart: Filtering Countries by Currency Source: https://github.com/tsinis/sealed_world/blob/main/packages/sealed_countries/README.md Illustrates two methods for filtering countries based on their associated currencies: a simple `.where` approach for a single currency and a more advanced `.byCountryMap()` for multiple currencies. ```dart // Quick/simple way (more suitable for a single currency): final usdCountries = WorldCountry.list.where( // All countries using USD. (country) => country.currencies?.contains(const FiatUsd()) ?? false, ); // Advanced (more suitable for multiple currencies, [sorted by population](https://github.com/tsinis/sealed_world/blob/main/packages/sealed_countries/lib/src/collections/README.currencies.md)): final map = const [FiatUsd(), FiatEur()].byCountryMap(); // All countries using USD or EUR. final allCountries = {for (final list in map.values) ...list}; ``` -------------------------------- ### CMake: Configure Flutter library and dependencies Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/linux/flutter/CMakeLists.txt This section configures the Flutter library by finding PkgConfig modules for GTK, GLIB, and GIO. It sets variables for the Flutter library path, ICU data file, project build directory, and AOT library. It then defines an INTERFACE library target named 'flutter' and adds include directories and link libraries. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Configure Flutter C++ Wrapper for Plugins (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/windows/flutter/CMakeLists.txt This CMake code configures a static library for the Flutter C++ wrapper, specifically for plugin usage. It includes core implementation files and plugin-specific files, sets visibility to hidden, and links against the Flutter library. Dependencies are managed by 'flutter_assemble'. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) ``` -------------------------------- ### Executable Output Directory Configuration (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_flags/example/linux/CMakeLists.txt Sets the runtime output directory for the main executable to a subdirectory within the build directory. This is done to prevent users from running the unbundled copy of the executable, ensuring resources are correctly located. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Localize Country Names using CountriesLocaleMapper Source: https://github.com/tsinis/sealed_world/blob/main/packages/l10n_countries/README.md Demonstrates how to use the CountriesLocaleMapper class to localize country names. It shows creating an instance, providing ISO codes, and specifying main and fallback locales for translation. ```dart void main() { /// Create an instance of the mapper directly. final mapper = CountriesLocaleMapper(); /// Define some ISO codes to localize (e.g., `USA` for United States, /// `RUS` for Russian Federation, and `POL` for Poland). final isoCodes = {"USA", "RUS", "POL"}; /// Localize the codes with an optional main locale (e.g., "sk" for Slovak), /// and an optional fallback locale (e.g., "cs" for Czech). final localized = mapper.localize(isoCodes, mainLocale: "sk", fallbackLocale: "cs"); print("Names count: ${localized.length}"); // Prints: "Names count: 12". /// Print out the localized names. localized.forEach( (country, l10n) => print( 'Localized name of country with ISO code "${country.isoCode}" ' 'for locale "${country.locale}" is "$l10n"', ), ); } ``` -------------------------------- ### Add Flutter Assemble Dependency (CMake) Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/windows/runner/CMakeLists.txt Ensures that the Flutter build process (`flutter_assemble`) is completed before the main application target is built. This is a mandatory step for proper Flutter application compilation. ```cmake add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Add sealed_currencies to pubspec.yaml Source: https://github.com/tsinis/sealed_world/blob/main/packages/sealed_currencies/README.md This snippet shows how to add the sealed_currencies package as a project dependency in the pubspec.yaml file. No specific inputs or outputs, it's a configuration step. ```yaml dependencies: sealed_currencies: any ``` -------------------------------- ### CMake Function for Standard Target Settings Source: https://github.com/tsinis/sealed_world/blob/main/packages/world_countries/example/windows/CMakeLists.txt Applies common compilation features and options to a given target, including C++17 standard, warning levels, and specific compiler flags. It also defines preprocessor macros for debugging and Unicode support. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE \"$<$:_DEBUG>\") endfunction() ```