mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-07-08 01:30:28 +08:00
Migrate from dart:html to package:web
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
// ignore: avoid_web_libraries_in_flutter
|
import 'package:web/web.dart';
|
||||||
import 'dart:html';
|
|
||||||
|
|
||||||
bool get pointerIsMouse => window.matchMedia('(pointer: fine)').matches;
|
bool get pointerIsMouse => window.matchMedia('(pointer: fine)').matches;
|
||||||
bool get pointerIsTouch => window.matchMedia('(pointer: coarse)').matches;
|
bool get pointerIsTouch => window.matchMedia('(pointer: coarse)').matches;
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
// ignore: avoid_web_libraries_in_flutter
|
import 'dart:js_interop';
|
||||||
import 'dart:html';
|
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
import 'package:web/web.dart';
|
||||||
|
|
||||||
void saveFileWeb(
|
void saveFileWeb(
|
||||||
Uint8List data, String mimeType, String filenameWithoutExtension) {
|
Uint8List data, String mimeType, String filenameWithoutExtension) {
|
||||||
final blob = Blob([data], mimeType);
|
final blobOpts = BlobPropertyBag(type: mimeType);
|
||||||
final url = Url.createObjectUrlFromBlob(blob);
|
final blob = Blob([data.toJS].toJS, blobOpts);
|
||||||
final a = document.createElement("a") as AnchorElement;
|
final url = URL.createObjectURL(blob);
|
||||||
|
final a = document.createElement("a") as HTMLAnchorElement;
|
||||||
a.href = url;
|
a.href = url;
|
||||||
var ext = "";
|
var ext = "";
|
||||||
switch (mimeType) {
|
switch (mimeType) {
|
||||||
@@ -24,11 +25,11 @@ void saveFileWeb(
|
|||||||
}
|
}
|
||||||
a.download = "$filenameWithoutExtension$ext";
|
a.download = "$filenameWithoutExtension$ext";
|
||||||
a.click();
|
a.click();
|
||||||
Url.revokeObjectUrl(url);
|
URL.revokeObjectURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveUriWeb(String uri) {
|
void saveUriWeb(String uri) {
|
||||||
final a = document.createElement("a") as AnchorElement;
|
final a = document.createElement("a") as HTMLAnchorElement;
|
||||||
a.href = uri;
|
a.href = uri;
|
||||||
a.click();
|
a.click();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// ignore: avoid_web_libraries_in_flutter
|
import 'package:web/web.dart';
|
||||||
import 'dart:html';
|
|
||||||
|
|
||||||
void setTitleWeb(String title) {
|
void setTitleWeb(String title) {
|
||||||
Future.delayed(const Duration(milliseconds: 10), () {
|
Future.delayed(const Duration(milliseconds: 10), () {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// ignore: avoid_web_libraries_in_flutter
|
import 'package:web/web.dart';
|
||||||
import 'dart:html';
|
|
||||||
import 'package:user_agent_analyzer/user_agent_analyzer.dart';
|
import 'package:user_agent_analyzer/user_agent_analyzer.dart';
|
||||||
|
|
||||||
UserAgent? _ua;
|
UserAgent? _ua;
|
||||||
|
|||||||
Reference in New Issue
Block a user