I would like to use context to show a custom dialog from cool alert in getxcontroller method. I have created the following controller
class HomePageController extends GetxController {
@override
void onInit() {
super.onInit();
getData();
}
void getData(){
//perform http request here
//show cool alert
CoolAlert.show(
context: context, //here needs the build context
type: CoolAlertType.success
);
}
}
Am using this controller in my stateless widget like
class HomePage extends StatelessWidget {
HomePage({ Key? key }) : super(key: key);
final _c = Get.find<HomePageController>();
@override
Widget build(BuildContext context) {
return Container(
);
}
}
How can i get the current homepage BuildContext in the controller inorder to show the cool alert.