How do I show a showDialog without a Buildcontext in the sample code given below which has within a class that extends a HookWidget?
Currently, I am getting an Undefined name 'context'.
I am using the following package for state management of my app:
flutter_hooks: ^0.10.0
hooks_riverpod: ^0.3.0
Sample Code:
class HomeScreen extends HookWidget {
static String routeName = "/home";
PageController _pageController = PageController(initialPage: 1);
dynamic balanceAvailable = 0.0;
List<TransactionModel> transactionList = [];
_onRefresh(DragEndDetails details) async {
showDialog(
context: context,
builder: (BuildContext context) {
return Center(
child: SizedBox(
height: MediaQuery.of(context).size.height / 4,
width: MediaQuery.of(context).size.width / 2,
child: CircularProgressIndicator(
valueColor: new AlwaysStoppedAnimation<Color>(Colors.blue),
),
),
);
});
await Future.delayed(const Duration(seconds: 2));
Navigator.pop(context);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onVerticalDragEnd: _onRefresh,
child: PageView(
controller: _pageController,
children: [
MenuScreen(),
HomeBody(
value: balanceAvailable,
),
TransactionScreen(
transactionList: transactionList,
value: balanceAvailable,
),
],
),
),
);
}
}
