Replace deprecated dart:html with package:web
- Updated document_viewer.dart to use web.HTMLIFrameElement/HTMLDivElement - Updated file_explorer.dart to use web.HTMLAnchorElement for downloads - Added web and http packages to pubspec.yaml
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:html' as html;
|
import 'package:web/web.dart' as web;
|
||||||
import 'dart:ui_web' as ui;
|
import 'dart:ui_web' as ui;
|
||||||
import '../theme/app_theme.dart';
|
import '../theme/app_theme.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@@ -471,7 +471,7 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
|
|||||||
|
|
||||||
ui.platformViewRegistry.registerViewFactory(viewType, (int viewId) {
|
ui.platformViewRegistry.registerViewFactory(viewType, (int viewId) {
|
||||||
// Create iframe pointing to the proxy endpoint
|
// Create iframe pointing to the proxy endpoint
|
||||||
final iframe = html.IFrameElement()
|
final iframe = web.HTMLIFrameElement()
|
||||||
..style.border = 'none'
|
..style.border = 'none'
|
||||||
..style.width = '100%'
|
..style.width = '100%'
|
||||||
..style.height = '100%'
|
..style.height = '100%'
|
||||||
@@ -487,7 +487,7 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
|
|||||||
'allow-same-origin allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms allow-presentation',
|
'allow-same-origin allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms allow-presentation',
|
||||||
);
|
);
|
||||||
|
|
||||||
final container = html.DivElement()
|
final container = web.HTMLDivElement()
|
||||||
..style.width = '100%'
|
..style.width = '100%'
|
||||||
..style.height = '100%'
|
..style.height = '100%'
|
||||||
..style.margin = '0'
|
..style.margin = '0'
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:file_picker/file_picker.dart' hide FileType;
|
import 'package:file_picker/file_picker.dart' hide FileType;
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'dart:html' as html;
|
import 'package:web/web.dart' as web;
|
||||||
import '../blocs/file_browser/file_browser_bloc.dart';
|
import '../blocs/file_browser/file_browser_bloc.dart';
|
||||||
import '../blocs/file_browser/file_browser_event.dart';
|
import '../blocs/file_browser/file_browser_event.dart';
|
||||||
import '../blocs/file_browser/file_browser_state.dart';
|
import '../blocs/file_browser/file_browser_state.dart';
|
||||||
@@ -291,9 +291,10 @@ class _FileExplorerState extends State<FileExplorer> {
|
|||||||
final fullUrl = '${fileService.baseUrl}$downloadUrl';
|
final fullUrl = '${fileService.baseUrl}$downloadUrl';
|
||||||
|
|
||||||
// Trigger download via anchor element
|
// Trigger download via anchor element
|
||||||
html.AnchorElement(href: fullUrl)
|
final anchor = web.HTMLAnchorElement()
|
||||||
..setAttribute('download', file.name)
|
..href = fullUrl
|
||||||
..click();
|
..download = file.name;
|
||||||
|
anchor.click();
|
||||||
|
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
ScaffoldMessenger.of(
|
ScaffoldMessenger.of(
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "2.0.1"
|
||||||
http:
|
http:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: http
|
name: http
|
||||||
sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412"
|
sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412"
|
||||||
@@ -1422,7 +1422,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.2.0"
|
||||||
web:
|
web:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: web
|
name: web
|
||||||
sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a"
|
sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a"
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ dependencies:
|
|||||||
infinite_scroll_pagination: ^5.1.1
|
infinite_scroll_pagination: ^5.1.1
|
||||||
collection: ^1.18.0
|
collection: ^1.18.0
|
||||||
syncfusion_flutter_pdfviewer: ^31.1.21
|
syncfusion_flutter_pdfviewer: ^31.1.21
|
||||||
|
web: ^1.1.0
|
||||||
|
http: ^1.2.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user