Skip to content

Commit 48d5d91

Browse files
committed
refactor: migrate web localstorage to web package
1 parent e774570 commit 48d5d91

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
// ignore: avoid_web_libraries_in_flutter
2-
import 'dart:html' as html;
1+
import 'package:web/web.dart';
32

4-
final _localStorage = html.window.localStorage;
3+
final _localStorage = window.localStorage;
54

65
Future<bool> hasAccessToken(String persistSessionKey) async =>
7-
_localStorage.containsKey(persistSessionKey);
6+
_localStorage.getItem(persistSessionKey) != null;
87

98
Future<String?> accessToken(String persistSessionKey) async =>
10-
_localStorage[persistSessionKey];
9+
_localStorage.getItem(persistSessionKey);
1110

1211
Future<void> removePersistedSession(String persistSessionKey) async =>
13-
_localStorage.remove(persistSessionKey);
12+
_localStorage.removeItem(persistSessionKey);
1413

1514
Future<void> persistSession(
1615
String persistSessionKey, persistSessionString) async =>
17-
_localStorage[persistSessionKey] = persistSessionString;
16+
_localStorage.setItem(persistSessionKey, persistSessionString);

packages/supabase_flutter/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dependencies:
2222
path_provider: ^2.0.0
2323
shared_preferences: ^2.0.0
2424
logging: ^1.2.0
25+
web: '>=0.5.0 <2.0.0'
2526

2627
dev_dependencies:
2728
dart_jsonwebtoken: ^2.4.1

0 commit comments

Comments
 (0)