Fix updating a Provider in build.

This commit is contained in:
Dain Nilsson 2024-02-05 14:11:17 +01:00
parent 7949dfdfb9
commit c82b147d66
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8
2 changed files with 14 additions and 9 deletions

View File

@ -87,12 +87,16 @@ Future<Widget> initialize() async {
child: DismissKeyboard(
child: YubicoAuthenticatorApp(page: Consumer(
builder: (context, ref, child) {
// Hardcoded feature set
ref.read(featureFlagProvider.notifier)
..setFeature(features.fido, false)
..setFeature(features.piv, false)
..setFeature(features.otp, false)
..setFeature(features.management, false);
Timer.run(() {
ref.read(featureFlagProvider.notifier)
// TODO: Load feature flags from file/config?
//..loadConfig(config)
// Disable unimplemented feature
..setFeature(features.fido, false)
..setFeature(features.piv, false)
..setFeature(features.otp, false)
..setFeature(features.management, false);
});
// activates window state provider
ref.read(androidWindowStateProvider);

View File

@ -233,17 +233,18 @@ Future<Widget> initialize(List<String> argv) async {
// Load feature flags, if they exist
featureFile.exists().then(
(exists) async {
final featureFlag = ref.read(featureFlagProvider.notifier);
if (exists) {
try {
final featureConfig =
jsonDecode(await featureFile.readAsString());
ref
.read(featureFlagProvider.notifier)
.loadConfig(featureConfig);
featureFlag.loadConfig(featureConfig);
} catch (error) {
_log.error('Failed to parse feature flags', error);
}
}
// Hardcode features here:
// featureFlag.setFeature(feature, false);
},
);