Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只是想知道,如果 dio 包默认使用隔离,如果它不使用隔离,那么我该如何使用它们。因为我的 API 会获取大量数据并且在 UI 线程上解码 json 可能不是一个好主意。
不,它默认不使用隔离。
如果要在一个隔离中解析 json,可以使用颤振计算函数在隔离中运行它。
您可以在 dio 的示例应用程序中找到使用它的示例:lib/main.dart#L16
Dio 有一个名为dio_flutter_transformer的插件,专门用于 Flutter,它将通过计算函数在单独的 Isolate 中解析 Json。
查看 pub 上的 Dio 包以查看可用插件列表:
https://pub.dev/packages/dio