flutter - 在 Flutter 中显示国旗字符
问题描述
这个答案有一些代码可以将语言环境转换为 Java 中的国家/地区表情符号。我尝试在 Dart 中实现它,但没有成功。
我尝试将上面的代码转换为 Dart
void _emoji() {
int flagOffset = 0x1F1E6;
int asciiOffset = 0x41;
String country = "US";
int firstChar = country.codeUnitAt(0) - asciiOffset + flagOffset;
int secondChar = country.codeUnitAt(1) - asciiOffset + flagOffset;
String emoji =
String.fromCharCode(firstChar) + String.fromCharCode(secondChar);
print(emoji);
}
“美国”语言环境应输出“”
解决方案
推荐阅读
- php - 用于数据库插入的 PHP 拆解数组
- sql - 如何确定 SQL Server“查找孤岛”(连续行)中的连续日期计数/天数
- arrays - 如何检查复杂数组中的相似数据
- linux - 有没有办法“回响”到标准输出什么被重定向为标准输入到程序(Unix)?
- for-loop - if, else if, 有没有更好的方法让我运行这段代码?
- android - Firebase 数据库访问 && 安全规则
- c# - char[] vs char 在方法的参数中。这是 MS 文档中的错误吗?
- mongodb - 如何在 spring-data mongodb 中使用 updateOption 和 arrayFilters?
- c - 列出我声明的函数的 C IDE
- ajax - “启用 AJAX 添加到存档上的购物车按钮”不起作用