Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasm Support #108

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/localstorage.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './src/interface.dart';
import './src/localstorage_io.dart'
if (dart.library.html) './src/localstorage_web.dart';
if (dart.library.js_util) './src/localstorage_web.dart';

export './src/interface.dart';

Expand Down
10 changes: 5 additions & 5 deletions lib/src/localstorage_web.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ignore: avoid_web_libraries_in_flutter
import 'dart:html' show window;
import 'package:web/web.dart' show window;
import './interface.dart';

Future<LocalStorage> init() async {
Expand All @@ -14,16 +14,16 @@ final class LocalStorageImpl implements LocalStorage {
void clear() => window.localStorage.clear();

@override
String? getItem(String key) => window.localStorage[key];
String? getItem(String key) => window.localStorage.getItem(key);

@override
String? key(int index) => window.localStorage.keys.elementAt(index);
String? key(int index) => window.localStorage.key(index);

@override
void removeItem(String key) => window.localStorage.remove(key);
void removeItem(String key) => window.localStorage.removeItem(key);

@override
void setItem(String key, String value) {
window.localStorage[key] = value;
window.localStorage.setItem(key, value);
}
}