dart format
This commit is contained in:
@@ -23,8 +23,10 @@ class ConfirmDialog extends StatelessWidget {
|
||||
this.onConfirm,
|
||||
this.onConfirmAsync,
|
||||
this.errorBuilder,
|
||||
}) : assert(onConfirm != null || onConfirmAsync != null,
|
||||
'ConfirmDialog requires either onConfirm or onConfirmAsync');
|
||||
}) : assert(
|
||||
onConfirm != null || onConfirmAsync != null,
|
||||
'ConfirmDialog requires either onConfirm or onConfirmAsync',
|
||||
);
|
||||
|
||||
void asDialog(BuildContext context) {
|
||||
showDialog(context: context, builder: build);
|
||||
@@ -32,32 +34,32 @@ class ConfirmDialog extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => AlertDialog(
|
||||
icon: icon != null ? Icon(icon) : null,
|
||||
title: Text(title),
|
||||
content: Text(content),
|
||||
actions: onConfirmAsync != null
|
||||
? [
|
||||
AsyncDialogAction(
|
||||
confirmLabel: confirmButton,
|
||||
cancelLabel: cancelButton,
|
||||
onConfirm: onConfirmAsync!,
|
||||
errorBuilder: errorBuilder,
|
||||
),
|
||||
]
|
||||
: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(cancelButton),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
onConfirm!();
|
||||
},
|
||||
child: Text(confirmButton),
|
||||
),
|
||||
],
|
||||
);
|
||||
icon: icon != null ? Icon(icon) : null,
|
||||
title: Text(title),
|
||||
content: Text(content),
|
||||
actions: onConfirmAsync != null
|
||||
? [
|
||||
AsyncDialogAction(
|
||||
confirmLabel: confirmButton,
|
||||
cancelLabel: cancelButton,
|
||||
onConfirm: onConfirmAsync!,
|
||||
errorBuilder: errorBuilder,
|
||||
),
|
||||
]
|
||||
: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(cancelButton),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
onConfirm!();
|
||||
},
|
||||
child: Text(confirmButton),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
static void openBrowser(BuildContext context, String url) {
|
||||
showDialog(
|
||||
@@ -66,7 +68,8 @@ class ConfirmDialog extends StatelessWidget {
|
||||
title: 'Link öffnen',
|
||||
content: 'Möchtest du den folgenden Link öffnen?\n$url',
|
||||
confirmButton: 'Öffnen',
|
||||
onConfirm: () => launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication),
|
||||
onConfirm: () =>
|
||||
launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user