【发布时间】:2021-10-12 20:16:21
【问题描述】:
我正在尝试在颤振中使用 ProfanityFilter 来过滤评论内容中的坏词,这是一个字符串。 ProfanityFilter 有一个审查词列表,我想将其与未包含在LDNOOBW list 中的脏话列表一起传递。但是,由于内容是字符串,所以我使用了强制转换,然后我得到了强制转换错误:type 'ProfanityFilter' is not a subtype of type 'String' in type cast.
TextFormField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.comment_outlined, color:
Colors.white60, size: 20,),
hintText: Languages
.of(context)
.revHint,
focusedBorder: UnderlineInputBorder(),
),
maxLines: null,
onChanged: (val) {
setState(() {
val = ProfanityFilter.filterAdditionally(badString) as String;
content = val;
viewModel.setDescription(content);
});
}
),
如何将字符串传递给列表,扫描然后将审查后的列表解析为字符串?或者有没有更好更简单的方法来审查坏词?可能是地图?谢谢!对 Flutter 和编码非常陌生。
【问题讨论】:
-
您是在使用这个textformfield添加新的坏词,还是在检查输入到textformfield的字符串是否包含坏词?
-
检查输入的字符串是否有坏词。
标签: string list flutter profanity