小编use*_*407的帖子

如何在searchDelegate上突出显示正确的单词?

我突出显示了这个词,但不是正确的词。

在我的 BuilderSuggection 中,我添加了这样的代码,

检查我的搜索委托

 title: RichText(
          text: TextSpan(
              text: suggestList[index].d.substring(0, query.length),
              style: TextStyle(
                  color: Colors.black, fontWeight: FontWeight.bold),
              children: [
            TextSpan(
                text: suggestList[index].d.substring(query.length),
                style: TextStyle(color: Colors.grey))
          ])),
Run Code Online (Sandbox Code Playgroud)

dart flutter

6
推荐指数
2
解决办法
2152
查看次数

未处理的异常:RangeError(索引):无效值:有效值范围为空:0

此方法始终运行。我检查了API。如果 API 值更改,我将删除我的数据库并再次插入。像这种情况一样使用正确的方法吗?(可以使用streamWidget还是FutureWidget?如果可以如何?)

错误信息:

[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] 未处理的异常:RangeError(索引):无效值:有效值范围为空:0

 checkQuick(String url, String token) async {
    result =
        (await HelperDatabase1().displayGetUserPreference()).elementAt(0)?.data;
    final response = await http.get(
      '$url/nativeapi/v1.0/User/GetUserPreference',
      headers: {'Authorization': 'Bearer $token'},
    );
    final jsonResponse = json.decode(response.body);
    GetUserPreference model = GetUserPreference.fromJson(jsonResponse);
    var data = GetUserPreference(data: model.data);

    if (result != data.data) {
      await HelperDatabase1().deleteGetUserPreference();
      await HelperDatabase1().storeGetUserPreference(url, token);
    }
  }
Run Code Online (Sandbox Code Playgroud)

dart flutter

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

dart ×2

flutter ×2