logo和名称替换
This commit is contained in:
+9
-5
@@ -2,7 +2,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
import 'package:hgmj/tools_base/debug_log.dart';
|
||||
import 'package:wydj/tools_base/debug_log.dart';
|
||||
import 'package:http/http.dart' hide Response;
|
||||
|
||||
import '../../extension/extensions.dart';
|
||||
@@ -16,7 +16,8 @@ class DioFileService extends FileService {
|
||||
final _dio = createDio();
|
||||
|
||||
@override
|
||||
Future<FileServiceResponse> get(String url, {Map<String, String>? headers = const {}}) async {
|
||||
Future<FileServiceResponse> get(String url,
|
||||
{Map<String, String>? headers = const {}}) async {
|
||||
// cancelToken 用文件名注册、下载结束后按同一 key 移除
|
||||
//(原来 createToken 用 name 而 remove 用 url,key 不一致:既移不掉导致泄漏,又会 firstWhere 抛 StateError)
|
||||
final name = FileUtil.getName(url);
|
||||
@@ -35,7 +36,8 @@ class DioFileService extends FileService {
|
||||
Response<ResponseBody>? resp;
|
||||
try {
|
||||
debugLog("DioFileService get: $url");
|
||||
resp = await _dio.get<ResponseBody>(url, cancelToken: token, options: options);
|
||||
resp = await _dio.get<ResponseBody>(url,
|
||||
cancelToken: token, options: options);
|
||||
} catch (e) {
|
||||
debugLog("DioFileService get error: $url -> $e");
|
||||
} finally {
|
||||
@@ -53,9 +55,11 @@ class DioFileService extends FileService {
|
||||
if (values.notEmpty()) respHeaders[key] = values.first;
|
||||
});
|
||||
// Content-Length 可能缺失/非数字,安全解析(原 contentLengthS[0] 在空串时会 RangeError);缺失传 null 表示长度未知
|
||||
final contentLength = int.tryParse(respHeaders[Headers.contentLengthHeader] ?? '');
|
||||
final contentLength =
|
||||
int.tryParse(respHeaders[Headers.contentLengthHeader] ?? '');
|
||||
|
||||
debugLog("DioFileService resp($statusCode): $url contentLength:$contentLength");
|
||||
debugLog(
|
||||
"DioFileService resp($statusCode): $url contentLength:$contentLength");
|
||||
|
||||
return HttpGetResponse(StreamedResponse(
|
||||
resp.data!.stream,
|
||||
|
||||
Reference in New Issue
Block a user