dart format

This commit is contained in:
2025-11-10 16:50:29 +05:30
parent d6f61ebb31
commit 8cfca113bf
28 changed files with 1995 additions and 1973 deletions

View File

@@ -14,24 +14,25 @@ class AuthToken extends Equatable {
required this.tnc,
});
factory AuthToken.fromJson(Map<String, dynamic> json) {
final token = json['token'];
factory AuthToken.fromJson(Map<String, dynamic> json) {
final token = json['token'];
// Safely extract tnc.mobile directly from the outer JSON
bool tncMobileValue = false; // Default to false if not found or invalid
if (json.containsKey('tnc') && json['tnc'] is Map<String, dynamic>) {
final tncMap = json['tnc'] as Map<String, dynamic>;
if (tncMap.containsKey('mobile') && tncMap['mobile'] is bool) {
tncMobileValue = tncMap['mobile'] as bool;
// Safely extract tnc.mobile directly from the outer JSON
bool tncMobileValue = false; // Default to false if not found or invalid
if (json.containsKey('tnc') && json['tnc'] is Map<String, dynamic>) {
final tncMap = json['tnc'] as Map<String, dynamic>;
if (tncMap.containsKey('mobile') && tncMap['mobile'] is bool) {
tncMobileValue = tncMap['mobile'] as bool;
}
}
}
return AuthToken(
accessToken: token,
expiresAt: _decodeExpiryFromToken(token), // This method is still valid for JWT expiry
tnc: tncMobileValue, // Use the correctly extracted value
);
}
return AuthToken(
accessToken: token,
expiresAt: _decodeExpiryFromToken(
token), // This method is still valid for JWT expiry
tnc: tncMobileValue, // Use the correctly extracted value
);
}
static DateTime _decodeExpiryFromToken(String token) {
try {
@@ -55,7 +56,7 @@ class AuthToken extends Equatable {
return DateTime.now().add(const Duration(hours: 1));
}
}
// static bool _decodeTncFromToken(String token) {
// try {
// final parts = token.split('.');