flutter - SemanticsService.announce 在颤振中
问题描述
正在浏览一个颤振库的代码,发现它正在被使用
SemanticsService.announce(
localizations.formatMonthYear(_selectedFirstDate), textDirection);
做了谷歌搜索并阅读了颤振文档,但仍然不确定这是做什么的。任何人都可以向我解释这一点或指向一些涵盖这一点的资源吗?
解决方案
这是关于可访问性。你可以看看,该方法的作用:
/// Sends a semantic announcement.
///
/// This should be used for announcement that are not seamlessly announced by
/// the system as a result of a UI state change.
///
/// For example a camera application can use this method to make accessibility
/// announcements regarding objects in the viewfinder.
static Future<void> announce(String message, TextDirection textDirection) async {
final AnnounceSemanticsEvent event = AnnounceSemanticsEvent(message, textDirection);
await SystemChannels.accessibility.send(event.toMap());
}
所以基本上屏幕阅读器(VoiceOver / Talkback)会读出消息参数中传递的内容。
推荐阅读
- scala - 值 get 不是 java.io.Serializable 的成员
- python - 为什么加入 numpy 数组比加入列表需要更长的时间?
- linux - 在入口点执行 sh 命令
- python - 按日期索引上的条件过滤 DataFrame
- ruby-on-rails - Facebook Messenger bot:postback.reply webhook 与数据库查询不匹配
- reactjs - 单击时未调用 onClick 事件
- python - 什么是依赖于 tensorflow 后端的文档到向量方法 (doc2vec)
- html - Bootstrap DatePicker,如何将开始日期设置为第二天上午 12 点?
- javascript - ember-power-select 中的自定义和第一个选项
- java - java my array runs with for loops, but nothing displays?