From 9ebe0ad98a7edbac58aad71173c840f8f5e0f735 Mon Sep 17 00:00:00 2001 From: Sai Rajendra Immadi Date: Mon, 26 Feb 2024 14:44:30 +0530 Subject: [PATCH] refactor: make use of web instead of dart:html (#112) with the new flutter version, the dart:html will not be working infavour of the new web package. This commit changes to use the web package instead --- lib/src/platform_utils/web.dart | 8 +++----- pubspec.yaml | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/src/platform_utils/web.dart b/lib/src/platform_utils/web.dart index 58761be..6d68728 100644 --- a/lib/src/platform_utils/web.dart +++ b/lib/src/platform_utils/web.dart @@ -1,20 +1,18 @@ -// ignore: avoid_web_libraries_in_flutter -import 'dart:html'; - import 'package:dashbook/dashbook.dart'; import 'package:dashbook/src/story_util.dart'; +import 'package:web/web.dart' as web; class PlatformUtils { PlatformUtils._(); static String getChapterUrl(Chapter chapter) { final plainUrl = - window.location.href.replaceFirst(window.location.hash, ''); + web.window.location.href.replaceFirst(web.window.location.hash, ''); return '$plainUrl#/${Uri.encodeComponent(chapter.id)}'; } static Chapter? getInitialChapter(List stories) { - final hash = window.location.hash; + final hash = web.window.location.hash; if (hash.isNotEmpty) { final currentId = Uri.decodeComponent(hash.substring(2)); diff --git a/pubspec.yaml b/pubspec.yaml index 6d6ad71..fcffef1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: flutter_markdown: ^0.6.17+3 shared_preferences: ^2.2.1 url_launcher: ^6.1.14 + web: ^0.5.0 dev_dependencies: flutter_test: