Added download
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export 'file_download_stub.dart' if (dart.library.js) 'file_download_web.dart' if (dart.library.io) 'file_download_app.dart';
|
||||
@@ -0,0 +1,3 @@
|
||||
Future<void> downloadFile(List<int> bytes, String fileName) {
|
||||
throw UnsupportedError('File download not supported on this platform');
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Future<void> downloadFile(List<int> bytes, String fileName) {
|
||||
throw UnsupportedError('Cannot download file on this platform');
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
|
||||
Future<void> downloadFile(List<int> bytes, String fileName) async {
|
||||
await FilePicker.platform.saveFile(
|
||||
dialogTitle: fileName,
|
||||
fileName: fileName,
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['pdf'],
|
||||
bytes: Uint8List.fromList(bytes),
|
||||
);
|
||||
}
|
||||
@@ -3,30 +3,30 @@ abstract class JwtTokenStorage {
|
||||
///
|
||||
/// @param accessToken The short-lived access token
|
||||
/// @param refreshToken The long-lived refresh token
|
||||
Future<void> saveTokens(String accessToken, String refreshToken);
|
||||
void saveTokens(String accessToken, String refreshToken);
|
||||
|
||||
/// Get the stored access token
|
||||
///
|
||||
/// @return Access token or null if not found
|
||||
Future<String?> getAccessToken();
|
||||
String? getAccessToken();
|
||||
|
||||
/// Get the stored refresh token
|
||||
///
|
||||
/// @return Refresh token or null if not found
|
||||
Future<String?> getRefreshToken();
|
||||
String? getRefreshToken();
|
||||
|
||||
/// Clear all stored tokens (on logout)
|
||||
Future<void> clearTokens();
|
||||
void clearTokens();
|
||||
|
||||
/// Check if tokens are stored
|
||||
///
|
||||
/// @return true if access token exists
|
||||
Future<bool> hasTokens();
|
||||
bool hasTokens();
|
||||
|
||||
/// Update only the access token (used after refresh)
|
||||
///
|
||||
/// @param accessToken New access token
|
||||
Future<void> updateAccessToken(String accessToken);
|
||||
void updateAccessToken(String accessToken);
|
||||
}
|
||||
|
||||
class JwtTokenStorageImpl extends JwtTokenStorage {
|
||||
@@ -36,34 +36,34 @@ class JwtTokenStorageImpl extends JwtTokenStorage {
|
||||
String? _keyRefreshToken;
|
||||
|
||||
@override
|
||||
Future<void> saveTokens(String accessToken, String refreshToken) async {
|
||||
void saveTokens(String accessToken, String refreshToken) async {
|
||||
_keyAccessToken = accessToken;
|
||||
_keyRefreshToken = refreshToken;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> getAccessToken() async {
|
||||
String? getAccessToken() {
|
||||
return _keyAccessToken;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> getRefreshToken() async {
|
||||
String? getRefreshToken() {
|
||||
return _keyRefreshToken;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> clearTokens() async {
|
||||
void clearTokens() {
|
||||
_keyAccessToken = null;
|
||||
_keyRefreshToken = null;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> hasTokens() async {
|
||||
bool hasTokens() {
|
||||
return _keyAccessToken != null && _keyAccessToken!.isNotEmpty;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateAccessToken(String accessToken) async {
|
||||
void updateAccessToken(String accessToken) {
|
||||
_keyAccessToken == accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user