showImportFailedDialog function
- BuildContext context,
- List<
String> errors
Shows import failed dialog with errors.
Implementation
Future<void> showImportFailedDialog(
BuildContext context,
List<String> errors,
) async {
await showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: const Row(
children: [
Icon(Icons.error_outline, color: Colors.red),
SizedBox(width: 8),
Text('Import Failed'),
],
),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('No valid places found in the file.'),
const SizedBox(height: 12),
const Text(
'Errors:',
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
...errors
.take(10)
.map(
(e) => Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Text(
'• $e',
style: TextStyle(
fontSize: 12,
color: Colors.red.shade700,
),
),
),
),
if (errors.length > 10)
Text(
'... and ${errors.length - 10} more errors',
style: const TextStyle(
fontSize: 12,
fontStyle: FontStyle.italic,
),
),
],
),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx),
child: const Text('OK'),
),
],
),
);
}