How do I display an alert dialog in flutter without user interaction?
I have a Widget that shows a ListView
. When a specific condition is true, I want to display an alert dialog within the same widget (everything is a widget in Flutter, right?). So no user interaction is needed.
this is the build method of my widget:
@override
Widget build(BuildContext context, WidgetRef ref) {
final providerData = ref.watch(someProvider);
//showAlertDialog(context);
final anotherProviderData = ref.watch(anotherProvider);
return anotherProviderData.when(
data: (entries) {
return CustomScrollView(...
I want to display an AlertDialog
based upon the provider data.
2
Answers
I figured out how to do it:
showAlertDialog(context)
is the method showing the alert dialog.You can call
showDialog
from a function you call based upon your trigger.