dioerror [dioerrortype.connectTimeOut]:连接时间熄灭[0ms]
abstract class ApiCalls {
Future<NoteModel?> createNote(NoteModel value);
Future<List<NoteModel?>> getAllNotes();
Future<NoteModel?> updateNote(NoteModel value);
Future<void> deleteNote(String id);
}
class NoteDB extends ApiCalls {
final dio = Dio();
final url = Url();
@override
Future<NoteModel?> createNote(NoteModel value) async {
try {
final _result = await dio.post<NoteModel>(
url.baseUrl + url.addNote,
data: value.toJson(),
);
return _result.data;
} on DioError catch (e) {
print(e.response?.data);
print(e);
} catch (e) {
print(e.toString());
}
}
仍然无法创建。 当Savenote连接到保存图标时,从控制台显示的错误说:
flutter (30312): null
I/flutter (30312): DioError [DioErrorType.connectTimeout]: Connecting timed out [0ms]
I/flutter (30312): Source stack:
I/flutter (30312): #0 DioMixin.fetch
package:dio/src/dio_mixin.dart:488
I/flutter (30312): #1 DioMixin.request
package:dio/src/dio_mixin.dart:483
I/flutter (30312): #2 DioMixin.post
package:dio/src/dio_mixin.dart:97
可以将其送到控制台和API。无效异常被抛出,但在尝试使用和捕获后仍显示出来。 如何解决连接时间的[0ms],或者在哪里应该将持续时间[0]更改为[3000]。
abstract class ApiCalls {
Future<NoteModel?> createNote(NoteModel value);
Future<List<NoteModel?>> getAllNotes();
Future<NoteModel?> updateNote(NoteModel value);
Future<void> deleteNote(String id);
}
class NoteDB extends ApiCalls {
final dio = Dio();
final url = Url();
@override
Future<NoteModel?> createNote(NoteModel value) async {
try {
final _result = await dio.post<NoteModel>(
url.baseUrl + url.addNote,
data: value.toJson(),
);
return _result.data;
} on DioError catch (e) {
print(e.response?.data);
print(e);
} catch (e) {
print(e.toString());
}
}
still not possible to create.
the error shown from the console while saveNote connected to save icon says:
flutter (30312): null
I/flutter (30312): DioError [DioErrorType.connectTimeout]: Connecting timed out [0ms]
I/flutter (30312): Source stack:
I/flutter (30312): #0 DioMixin.fetch
package:dio/src/dio_mixin.dart:488
I/flutter (30312): #1 DioMixin.request
package:dio/src/dio_mixin.dart:483
I/flutter (30312): #2 DioMixin.post
package:dio/src/dio_mixin.dart:97
can,t get it to the console and api. null exception is thrown but after try and catch used but still showing.
how can i solve Connecting timed out [0ms]or where should i change the time duration [0] to [3000].
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在
dio.options
中使用以下属性将其设置为默认配置。 来自文档:或您可以<代码>发布带有请求选项参数设置
ConnectTimeOut
和/或codeivetimeout
。 来自文档:You can use the following properties in
dio.options
to set it the default configurations. From the docs:Or you can
post
with the request options parameter settingconnectTimeout
and/orreceiveTimeout
. From the docs: