
Performs a comprehensive project rename from 'barcode_scanner' to 'e_scan' (or 'eScan' for user-facing labels). This update spans all relevant files, including: - Application IDs and bundle identifiers for Android, iOS, macOS, and Linux. - VS Code launch configurations. - Dart package import paths. - Project names and titles in `pubspec.yaml`, `README.md`, and platform-specific configurations (e.g., CMakeLists, Info.plist, AndroidManifest).
55 lines
1.4 KiB
Dart
55 lines
1.4 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:e_scan/provider_container.dart';
|
|
import 'package:e_scan/services/secure_storage.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'user_struct.freezed.dart';
|
|
part 'user_struct.g.dart';
|
|
|
|
@Freezed(toJson: true)
|
|
abstract class UserStruct with _$UserStruct {
|
|
factory UserStruct({
|
|
String? id,
|
|
String? image,
|
|
String? firstName,
|
|
String? lastName,
|
|
String? email,
|
|
String? phone,
|
|
}) = _UserStruct;
|
|
|
|
factory UserStruct.fromJson(Map<String, dynamic> json) =>
|
|
_$UserStructFromJson(json);
|
|
}
|
|
|
|
extension UserStructExt on UserStruct {
|
|
String get key => 'user';
|
|
|
|
String get fullName {
|
|
final sb = StringBuffer();
|
|
sb.write(firstName);
|
|
if (firstName != null) {
|
|
sb.write(' ');
|
|
}
|
|
sb.write(lastName);
|
|
return sb.toString();
|
|
}
|
|
|
|
Future setToLocalStorage() {
|
|
final storage = providerContainer.read(sharedPrefsProvider);
|
|
return storage.write(key: id ?? key, value: jsonEncode(toJson()));
|
|
}
|
|
|
|
Future<UserStruct?> getFromLocalStorage() async {
|
|
final storage = providerContainer.read(sharedPrefsProvider);
|
|
final jsonString = await storage.read(key: id ?? key);
|
|
if (jsonString == null) return null;
|
|
return UserStruct.fromJson(jsonDecode(jsonString));
|
|
}
|
|
|
|
Future<void> deleteLocalStorage() {
|
|
final storage = providerContainer.read(sharedPrefsProvider);
|
|
return storage.delete(key: id ?? key);
|
|
}
|
|
}
|