Skip to content

Commit

Permalink
Refactor ApplicationCustomizer provider to introduce initial state ma…
Browse files Browse the repository at this point in the history
…nagement
  • Loading branch information
frankmer committed Nov 29, 2024
1 parent b3fd3d6 commit c480779
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@ part 'application_customizer_provider.g.dart';
/// Only used for the app customizer
@riverpod
class ApplicationCustomizer extends _$ApplicationCustomizer {
@override
Future<ApplicationCustomization> build() async {
final customization = ApplicationCustomization.defaultCustomization.copyWith(disabledFeatures: AppFeature.values.toSet());
return customization;
static ApplicationCustomization get initialState =>
_initialState ?? ApplicationCustomization.defaultCustomization.copyWith(disabledFeatures: AppFeature.values.toSet());
static ApplicationCustomization? _initialState;

static void setInitialState(ApplicationCustomization initialState) {
_initialState = initialState;
}

@override
Future<ApplicationCustomization> build() async => initialState;

Future<ApplicationCustomization> setState(ApplicationCustomization newState) async {
state = AsyncValue.data(newState);
return newState;
Expand Down

0 comments on commit c480779

Please sign in to comment.