我正在用本地json文件构建Flatter应用程序,我的json看起来像
[
{
"category": "ملابس",
"count": 1,
"description": "ملابس رجالي",
"reference": "",
"color": "أحمر "
}
]
我需要用户在搜索时找到产品,例如 colored颜色 ,如果用户准确搜索"أحمИ",则效果很好,但如果输入的值为"احمД",则条件将为假,因此列表中不会出现任何内容.
搜索功能
Future<void> searchJson(query) async {
final jsondata = await rootBundle.loadString('assets/json/product.json');
final list = await json.decode(jsondata) as List<dynamic>;
List data = list
.where((map) => map['color']
.replaceAll(RegExp(String.fromCharCodes(arabicTashkelChar)), "")
.contains(query))
.toList();
setState(() {
items = data;
});
}
这是我的arabicTashkelChar
个特殊阿拉伯字符列表
const Iterable<int> arabicTashkelChar = [
1617,
124,
1614,
124,
1611,
124,
1615,
124,
1612,
124,
1616,
124,
1613,
124,
1618,
625,
627,
655,
];
我用arabicTashkelChar
英镑把这条线变成了阿拉伯语.
现在我想把string变成红色.