import 'package:shared_preferences/shared_preferences.dart'; import '../../core/servers/server_scope.dart'; const settingsTopicKey = 'pipelines.next.settingsTopic.v1'; abstract interface class SettingsTopicStore { Future load(); Future save(String topic); } /// Stores only the selected category, never unsaved fields or popup state. class SharedPreferencesSettingsTopicStore implements SettingsTopicStore { const SharedPreferencesSettingsTopicStore(this.scope); final String scope; String get key => scopedServerKey(settingsTopicKey, scope); @override Future load() async { try { return (await SharedPreferences.getInstance()).getString(key); } catch (_) { return null; } } @override Future save(String topic) async { try { await (await SharedPreferences.getInstance()).setString(key, topic); } catch (_) { // The mounted category remains usable when local storage is unavailable. } } }