fixes, improvements, and cleanup. notably, custom camera profiles make a comeback.

This commit is contained in:
stopflock
2025-07-19 20:22:20 -05:00
parent e290e11c5b
commit f8d71d0c75
10 changed files with 375 additions and 45 deletions
+29
View File
@@ -0,0 +1,29 @@
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
import '../models/camera_profile.dart';
class ProfileService {
static const _key = 'custom_profiles';
Future<List<CameraProfile>> load() async {
final prefs = await SharedPreferences.getInstance();
final jsonStr = prefs.getString(_key);
if (jsonStr == null) return [];
final list = jsonDecode(jsonStr) as List<dynamic>;
return list.map((e) => CameraProfile.fromJson(e)).toList();
}
Future<void> save(List<CameraProfile> profiles) async {
final prefs = await SharedPreferences.getInstance();
// MUST convert to List before jsonEncode; the previous MappedIterable
// caused "Converting object to an encodable object failed".
final encodable = profiles
.where((p) => !p.builtin)
.map((p) => p.toJson())
.toList(); // <- crucial
await prefs.setString(_key, jsonEncode(encodable));
}
}