build: 移除 Web 平台支持
删掉 web/ 目录与 4 个 *_web.dart 实现(jsQR/dart:html 解码、FileUploadInputElement 选图、以及为 Web 空实现的缓存与导出)。剩下 Android/iOS/Windows/macOS/Linux。 顺带把只剩单一实现的「façade + _native + _web」条件导入结构收敛成单文件, 调用点不变。同时从 .metadata 的 migration 平台列表和 analysis_options 的 exclude 里去掉 web,避免 flutter create/migrate 再把 web/ 生成回来。 QR 从图片解码此前只有 Web 端用 jsQR 真正可用,移动端走 MethodChannel 由 MainActivity/SceneDelegate 实现,桌面端无 handler——这一点在 qr_service.dart 和 README 里都注明了。 副作用:dart:html / dart:js 带来的 5 条 analyze info 随文件消失, flutter analyze 从 7 条降到 1 条(剩下的是 title_api_service 里既有的 prefer_initializing_formals)。
This commit is contained in:
1 parent
b6d55bf236
commit
cb50426a61
22 files changed
+78
-285
No files matched your search
@@ -1,10 +1,26 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'png_export_service_native.dart'
|
||||
if (dart.library.html) 'png_export_service_web.dart' as impl;
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
/// 导出一张 PNG:原生平台落临时盘并拉起系统分享,Web 走下载或 Web Share API。
|
||||
/// 导出一张 PNG:先落临时盘,再拉起系统分享面板。
|
||||
///
|
||||
/// 返回原生平台上的落盘路径(用于分享能力缺失时提示用户),Web 返回 null。
|
||||
Future<String?> exportPng(Uint8List bytes, String fileName) =>
|
||||
impl.exportPng(bytes, fileName);
|
||||
/// 返回落盘路径,供分享能力缺失时提示用户。Linux 与 Windows 10 RS5 之前
|
||||
/// 的 share_plus 不支持分享文件,会抛 UnimplementedError,此时文件仍在盘上。
|
||||
Future<String?> exportPng(Uint8List bytes, String fileName) async {
|
||||
final file = File('${Directory.systemTemp.path}/$fileName');
|
||||
await file.writeAsBytes(bytes);
|
||||
|
||||
try {
|
||||
await SharePlus.instance.share(
|
||||
ShareParams(
|
||||
files: [XFile.fromData(bytes, name: fileName, mimeType: 'image/png')],
|
||||
fileNameOverrides: [fileName],
|
||||
),
|
||||
);
|
||||
} on UnimplementedError {
|
||||
// 该平台不支持分享文件,文件已落盘,返回路径即可。
|
||||
}
|
||||
|
||||
return file.path;
|
||||
}
|
||||
Reference in new issue
Block a user