Today i'm wondering why i can't use context.read
inside HookWidget
after defining this codes into project:
class FavoriteAddressBottomSheet extends HookWidget {
@override
Widget build(BuildContext context) {
return Container(
child: Material(
color: Colors.transparent,
child: Container(
...
child: Column(
children: [
ValueListenableBuilder(
valueListenable: _address.listenable(),
builder: (BuildContext context, Box address, __) {
return Expanded(
child: ListView.builder(
padding: EdgeInsets.zero,
itemBuilder: (context, index) {
return GestureDetector(
onTap: ()=> context.read(orderStateNotifierProvider.notifier).updateAddress(),
child: Container(
...
);
},
itemCount: _address.length,
),
);
}),
],
),
),
),
),
);
}
}
my orderStateNotifierProvider
and updateAddress
are correct because i used more them into project, but when i try to use inside ListView
which ListView
wrapped into ValueListenableBuilder
i get this error:
The method 'read' isn't defined for the type 'BuildContext'.