diff --git a/packages/settings/lib/src/options/option.dart b/packages/settings/lib/src/options/option.dart index 6534d11e..7d529769 100644 --- a/packages/settings/lib/src/options/option.dart +++ b/packages/settings/lib/src/options/option.dart @@ -1,5 +1,7 @@ part of '../../settings.dart'; +class OptionDisableException implements Exception {} + abstract class Option { Option({ required this.storage, @@ -24,7 +26,13 @@ abstract class Option { late final BehaviorSubject enabled; late BehaviorSubject stream; - T get value => stream.value ?? defaultValue.value; + T get value { + if (!enabled.value) { + throw OptionDisableException(); + } + + return stream.value ?? defaultValue.value; + } void dispose() { // ignore: discarded_futures