-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Yasm1nNasc1mento <yasmin.mn4@gmail.com> Co-authored-by: dylancavalcante <dylanportelacavalcante@gmail.com>
- Loading branch information
1 parent
b54c3ef
commit 51658db
Showing
8 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | ||
import 'package:aranduapp/core/log/Log.dart'; | ||
|
||
class StorageValue { | ||
|
||
static const String _authToken = "auth_token"; | ||
static const String _refreshToken = "refresh_token"; | ||
static const String _email = "email"; | ||
static const String _name = "name"; | ||
|
||
static StorageValue? _singleton; | ||
final FlutterSecureStorage storage; | ||
|
||
StorageValue._internal() | ||
: storage = const FlutterSecureStorage( | ||
aOptions: AndroidOptions(encryptedSharedPreferences: true)); | ||
|
||
factory StorageValue.getInstance() => | ||
_singleton ??= StorageValue._internal(); | ||
|
||
Future<void> _setValue(String key, String value) async { | ||
try { | ||
await storage.write(key: key, value: value); | ||
} catch (e) { | ||
Log.e("Error while setting $key: $e"); | ||
} | ||
} | ||
|
||
Future<String?> _getValue(String key) async { | ||
try { | ||
return await storage.read(key: key); | ||
} catch (e) { | ||
Log.e("Error while getting $key: $e"); | ||
return null; | ||
} | ||
} | ||
|
||
Future<void> setAuthToken(String token) => _setValue(_authToken, token); | ||
Future<void> setRefreshToken(String token) => _setValue(_refreshToken, token); | ||
Future<void> setEmail(String email) => _setValue(_email, email); | ||
Future<void> setName(String name) => _setValue(_name, name); | ||
|
||
Future<String?> getAuthToken() => _getValue(_authToken); | ||
Future<String?> getRefreshToken() => _getValue(_refreshToken); | ||
Future<String?> getEmail() => _getValue(_email); | ||
Future<String?> getName() => _getValue(_name); | ||
|
||
Future<void> clear() async { | ||
try { | ||
await storage.deleteAll(); | ||
} catch (e) { | ||
Log.e("Error while clearing storage: $e"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# | ||
|
||
list(APPEND FLUTTER_PLUGIN_LIST | ||
flutter_secure_storage_linux | ||
) | ||
|
||
list(APPEND FLUTTER_FFI_PLUGIN_LIST | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# | ||
|
||
list(APPEND FLUTTER_PLUGIN_LIST | ||
flutter_secure_storage_windows | ||
local_auth_windows | ||
) | ||
|
||
|