我对某些网络请求充满了麻烦。但是奇怪的是,只要我触发了一个请求,一切都会正常,但是如果我快速按下两个按钮,它将在框架(io_client.dart)中抛出ClientException。
控制台中的消息是:
D/AwareBitmapCacher( 8890): handleInit switch not opened pid=8890
D/ZrHung.AppEyeUiProbe( 8890): stop checker.
W/libEGL ( 8890): EGLNativeWindowType 0x735464f010 disconnect failed
D/ViewRootImpl[MainActivity]( 8890): surface should not be released
W/libEGL ( 8890): EGLNativeWindowType 0x735464e010 disconnect failed
D/ZrHung.AppEyeUiProbe( 8890): Current Activity:false
D/ZrHung.AppEyeUiProbe( 8890): not watching, wait.
E/ ( 8890): [ZeroHung]zrhung_get_config: Get config failed for wp[0x0008]
I/_bus_controlle( 8890): Starting profile saver IsSaveProfileNow end.
D/ZrHung.AppEyeUiProbe( 8890): notify runnable to start.
D/ZrHung.AppEyeUiProbe( 8890): restart watching
D/mali_winsys( 8890): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/mali_winsys( 8890): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
E/BpSurfaceComposerClient( 8890): Failed to transact (-1)
E/BpSurfaceComposerClient( 8890): Failed to transact (-1)
W/InputMethodManager( 8890): startInputReason = 1
这是我的请求方法:
import 'package:http/http.dart' as http;
void sendRequest (String url, String apiPath, bool on) async {
String fullPath;
if(on) {
fullPath = 'http://' + url + '/' + apiPath + '/on';
} else {
fullPath = 'http://' + url + '/' + apiPath + '/off';
}
http.get(fullPath);
}
此函数调用sendRequest方法:
void _changeSwitchState(BackendDataWrapper wrapper, bool value) {
setState(() {
wrapper.alter(value);
});
sendRequest(widget.espUrl ,wrapper.sender, wrapper.boolean);
}
问题可能是两个按钮单击都触发相同的请求方法吗?还是在调用之前使用setState()方法有困难?还是网络服务器有问题(这是esp32,例如Arduino)?
我真的不知道,我之前曾通过Web请求进行过其他Flutter项目,但一切正常。
感谢您的想法!