loadFootprint method

  1. @override
Future<void> loadFootprint(
  1. String userId
)
override

Load an existing footprint for userId from persistence.

Implementation

@override
Future<void> loadFootprint(String userId) async {
  try {
    final box = await Hive.openBox(_hiveBox);
    final stored = box.get(userId);
    if (stored != null) {
      final json = Map<String, dynamic>.from(jsonDecode(stored as String));
      footprint.value = HarmonicFootprint.fromJson(json);
    } else {
      footprint.value = HarmonicFootprint(userId: userId);
    }
    update();
  } catch (e) {
    debugPrint('[HarmonicFootprint] Load error: $e');
    footprint.value = HarmonicFootprint(userId: userId);
    update();
  }
}