@@ -176,11 +176,13 @@ class _LinkedProvidersRow extends StatefulWidget {
176
176
final FirebaseAuth ? auth;
177
177
final List <AuthProvider > providers;
178
178
final VoidCallback onProviderUnlinked;
179
+ final bool showUnlinkConfirmationDialog;
179
180
180
181
const _LinkedProvidersRow ({
181
182
this .auth,
182
183
required this .providers,
183
184
required this .onProviderUnlinked,
185
+ required this .showUnlinkConfirmationDialog,
184
186
});
185
187
186
188
@override
@@ -207,7 +209,31 @@ class _LinkedProvidersRowState extends State<_LinkedProvidersRow> {
207
209
error = null ;
208
210
});
209
211
212
+ bool ? confirmed = ! widget.showUnlinkConfirmationDialog;
213
+
214
+ if (! confirmed) {
215
+ confirmed = await showAdaptiveDialog <bool ?>(
216
+ context: context,
217
+ builder: (context) {
218
+ return UniversalAlert (
219
+ onConfirm: () {
220
+ Navigator .of (context).pop (true );
221
+ },
222
+ onCancel: () {
223
+ Navigator .of (context).pop (false );
224
+ },
225
+ title: 'Unlink provider' ,
226
+ confirmButtonText: 'Unlink' ,
227
+ cancelButtonText: 'Cancel' ,
228
+ message: 'Are you sure you want to unlink this provider?' ,
229
+ );
230
+ },
231
+ );
232
+ }
233
+
210
234
try {
235
+ if (! (confirmed ?? false )) return ;
236
+
211
237
final user = widget.auth! .currentUser! ;
212
238
await user.unlink (providerId);
213
239
await user.reload ();
@@ -712,6 +738,10 @@ class ProfileScreen extends MultiProviderScreen {
712
738
/// are ignored.
713
739
final Widget ? avatar;
714
740
741
+ /// Indicates wether a confirmation dialog should be shown when the user
742
+ /// tries to unlink a provider.
743
+ final bool showUnlinkConfirmationDialog;
744
+
715
745
const ProfileScreen ({
716
746
super .key,
717
747
super .auth,
@@ -726,6 +756,7 @@ class ProfileScreen extends MultiProviderScreen {
726
756
this .cupertinoNavigationBar,
727
757
this .actionCodeSettings,
728
758
this .showMFATile = false ,
759
+ this .showUnlinkConfirmationDialog = false ,
729
760
});
730
761
731
762
Future <bool > _reauthenticate (BuildContext context) {
@@ -819,6 +850,7 @@ class ProfileScreen extends MultiProviderScreen {
819
850
auth: auth,
820
851
providers: linkedProviders,
821
852
onProviderUnlinked: providersScopeKey.rebuild,
853
+ showUnlinkConfirmationDialog: showUnlinkConfirmationDialog,
822
854
),
823
855
);
824
856
},
0 commit comments