-
I have the following code in static final provider = Provider.autoDispose<AreaOfExpertiseState>((ref) {
ref.watch(countries);
ref.watch(provinces);
ref.watch(areas);
final credentials = ref.watch(CacheController.provider).credentials;
final items = ref.watch(AreaOfExpertiseState.items).state;
items[AreaOfExpertise.COUNTRY]!.subtitle = Utils.joinSafe(credentials?.countries, ',');
items[AreaOfExpertise.PROVINCE]!.subtitle = Utils.joinSafe(credentials?.provinces, ',');
items[AreaOfExpertise.AREAS]!.subtitle = Utils.joinSafe(credentials?.areas, ',');
ref.watch(AreaOfExpertiseState.items).state = items; // this line throws the error
return AreaOfExpertiseState(ref.read);
});
static final isButtonLoading = StateProvider.autoDispose<bool>((ref) => false);
static final countries = StateProvider.autoDispose<List<String>>((ref) => ref.watch(CacheController.provider).credentials?.countries ?? []);
static final provinces = StateProvider.autoDispose<List<String>>((ref) => ref.watch(CacheController.provider).credentials?.provinces ?? []);
static final areas = StateProvider.autoDispose<List<String>>((ref) => ref.watch(CacheController.provider).credentials?.areas ?? []);
static final items = StateProvider.autoDispose<Map<AreaOfExpertise, AreaOfExpertiseItem>>((ref) => {
AreaOfExpertise.COUNTRY: AreaOfExpertiseItem(title: 'Country', areaOfExpertise: AreaOfExpertise.COUNTRY),
AreaOfExpertise.PROVINCE: AreaOfExpertiseItem(title: 'Province', areaOfExpertise: AreaOfExpertise.PROVINCE),
AreaOfExpertise.AREAS: AreaOfExpertiseItem(title: 'Area', areaOfExpertise: AreaOfExpertise.AREAS),
}); I've tried putting what Is there a way to solve this? I'm guessing this is because of the Stack trace
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This was a dumb question. I just did that in static final items = StateProvider.autoDispose<Map<AreaOfExpertise, AreaOfExpertiseItem>>((ref) {
final credentials = ref.watch(CacheController.provider).credentials;
return {
AreaOfExpertise.COUNTRY: AreaOfExpertiseItem(
title: 'Country',
areaOfExpertise: AreaOfExpertise.COUNTRY,
subtitle: Utils.joinSafe(credentials?.countries, ','),
),
AreaOfExpertise.PROVINCE: AreaOfExpertiseItem(
title: 'Province',
areaOfExpertise: AreaOfExpertise.PROVINCE,
subtitle: Utils.joinSafe(credentials?.provinces, ','),
),
AreaOfExpertise.AREAS: AreaOfExpertiseItem(
title: 'Area',
areaOfExpertise: AreaOfExpertise.AREAS,
subtitle: Utils.joinSafe(credentials?.areas, ','),
),
};
}); |
Beta Was this translation helpful? Give feedback.
This was a dumb question.
I just did that in
AreaOfExpertiseState.items
like this: