I am new to Flutter hooks and I have requirements that I have to use HookWidget instead of StatefulWidget. As I know, useState can only be declared within the build function.
Widget build(BuildContext context) {
final selectedBook = useState("");
return Container(
child: _buildBookListContainer(context)
)
}
Widget _buildBookListContainer(BuildContext context) {
//I will want to update the state value or read the state value in the child function
//how do I do that?
//Example: selectedBook.value = "xxx";
}
I tried passing down the state value as function arguments but it will not work. May I know that is it all HookWidget class will just write all components inside the build function without refractoring?