Skip to content

Commit

Permalink
chore: used private global variable for local storage key
Browse files Browse the repository at this point in the history
  • Loading branch information
khatruong2009 committed Sep 11, 2023
1 parent c045708 commit 94859b8
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
import 'dart:convert';
import 'dart:html';

// Declare a constant global private variable for the key
const String _localStorageKey = 'aws.cloudwatch.logging_constraint';

/// Save constraint locally to web storage
Future<void> saveConstraintLocally(Map<String, dynamic> constraint) async {
window.localStorage['logging_constraint'] = jsonEncode(constraint);
window.localStorage[_localStorageKey] = jsonEncode(constraint);
}

/// Load constraint from web storage
Map<String, dynamic>? loadConstraint() {
final content = window.localStorage['logging_constraint'];
final content = window.localStorage[_localStorageKey];
if (content != null) {
return jsonDecode(content) as Map<String, dynamic>;
}
Expand Down

0 comments on commit 94859b8

Please sign in to comment.