Skip to content

Commit

Permalink
refactor: make use of web instead of dart:html (#112)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
immadisairaj authored Feb 26, 2024
1 parent 90cca27 commit 9ebe0ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/src/platform_utils/web.dart
Original file line number Diff line number Diff line change
@@ -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<Story> stories) {
final hash = window.location.hash;
final hash = web.window.location.hash;

if (hash.isNotEmpty) {
final currentId = Uri.decodeComponent(hash.substring(2));
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9ebe0ad

Please sign in to comment.