import 'package:flutter/material.dart'; /// Fragt eine Pflicht-Begründung ab (z. B. für Pausieren/Abbrechen einer /// Lieferung). Liefert den getrimmten Text oder `null` bei Abbruch. Future showReasonDialog(BuildContext context, String title) async { // Controller bewusst nicht disposen: Der Dialog nutzt ihn noch während // der Schließ-Animation. Ohne Listener räumt der GC ihn ab. final controller = TextEditingController(); return showDialog( context: context, builder: (dialogContext) => AlertDialog( title: Text(title), content: TextField( controller: controller, autofocus: true, decoration: const InputDecoration( labelText: 'Grund', border: OutlineInputBorder(), ), ), actions: [ TextButton( onPressed: () => Navigator.of(dialogContext).pop(null), child: const Text('Abbrechen'), ), FilledButton( onPressed: () { final text = controller.text.trim(); if (text.isEmpty) return; Navigator.of(dialogContext).pop(text); }, child: const Text('Bestätigen'), ), ], ), ); }