【发布时间】:2020-09-03 12:06:32
【问题描述】:
我正在尝试从我的聊天机器人生成响应(使用对话流)
void response(query) async {
AuthGoogle authGoogle = await AuthGoogle(
fileJson: "Assets/amigo-pyhyyy-e2d1db5e1ee9.json").build();
Dialogflow dialogflow = await Dialogflow(
authGoogle: authGoogle, language: Language.english);
AIResponse aiResponse = await dialogflow.detectIntent(query);
setState(() {
messages.insert(0, {"data": 0,
"message": aiResponse.getListMessage()[0]["text"]["text"][0].tostring()
});
});
我收到此错误: E/flutter (8166): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] 未处理异常:NoSuchMethodError: 类 'String' 没有实例方法 'tostring'。
我尝试在 pubspec.yaml 中添加依赖项: 依赖关系: to_string: ^1.2.1 dev_dependencies: to_string_generator: ^1.2.1
但我仍然在我的控制台上收到回复,而不是在应用程序上收到机器人的回复。
好的耶耶耶!我确实将所有实例都更改为 .toString() ,而不是 .tostring() (这对我来说太愚蠢了......- __________-)
但现在我有一个错误: ════════ 小部件库捕获的异常══════════════════════════════════════════ ═════════════════════ 以下断言被抛出: type 'String' 不是 type 'Widget' 的子类型
【问题讨论】:
-
该方法被称为
toString。注意大写S
标签: flutter tostring nosuchmethoderror