I currently have a riverpod provider declared as follows:
@riverpod
class FeeInputData extends _$FeeInputData {
@override
Fee build() {
return const Fee(
id: 0,
institutionId: 'nmb7588BVjhvnb',
name: '',
academicYearId: 'utf896DHGFoIO7t87',
installments: [],
totalAmount: 0,
);
}
void updateName(String data) {
state = state.copyWith(name: data);
}
}
I have used the riverpod generator which generates an AutoDisposeNotifierProvider.
This is my Consumer widget which has a ListView.seperated as its child:
Consumer(
builder: (context, ref, _) {
final installments = ref.watch(feeInputDataProvider).installments;
return ListView.separated(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: installments.length,
separatorBuilder: (context, index) => Column(
children: [
SizedBox(height: SizeConfig(context).getVerticalSize(10)),
Row(
children: [
const Expanded(child: Divider(color: AppColors.kSubtitle, height: 0.5)),
SizedBox(width: SizeConfig(context).getHorizontalSize(5)),
/// Remove address button
AddRemoveButton(
type: AddRemoveButtonType.remove,
onTap: () {
ref.read(feeInputDataProvider.notifier).removeInstallment(index);
},
),
],
),
],
),
itemBuilder: (context, index) => InstallmentWidget(
installment: installments[index],
),
);
},
),
Now, the issue is that when I try to access the provider via Consumer widget, it returns the following error:
The following JSNoSuchMethodError was thrown building Consumer(dirty, dependencies:
[UncontrolledProviderScope], state: _ConsumerState#08454):
TypeError: Cannot read properties of undefined (reading 'prototype')
I have wrapped my MaterialApp with ProviderScope widget.
How do I fix this?