import 'package:flutter/material.dart'; import 'package:get/get.dart'; extension GetInterfaceExtension on GetInterface { Future confirm({ required String title, required String content, String yes = "Да", String no = "Нет", }) async { final result = await Get.defaultDialog( title: title, content: Text(content), textConfirm: yes, textCancel: no, onConfirm: () => Get.backLegacy(result: true), onCancel: () => Get.backLegacy(result: false), ); return result == true; } Future prompt({ required String title, String message = "", String hintText = "", String label = "", String defaultValue = "", String positiveLabel = "ОК", String negativeLabel = "Отмена", int? maxLength, int maxLines = 1, Widget? prefix, required String? Function(String? x) stringValidator, }) async { final controller = TextEditingController(text: defaultValue); final value = Get.dialog( AlertDialog( title: Text(title), content: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ if (message.isNotEmpty) Padding( padding: const EdgeInsets.only(bottom: 8), child: Text(message), ), TextFormField( controller: controller, decoration: InputDecoration( hintText: hintText, filled: true, prefix: prefix, label: Text(label), ), maxLength: maxLength, maxLines: maxLines, autovalidateMode: AutovalidateMode.onUserInteraction, validator: stringValidator, ) ], ), actions: [ ElevatedButton( onPressed: () { if (stringValidator(controller.value.text) == null) { Get.backLegacy(result: controller.value.text); } }, child: Text(positiveLabel), ), ElevatedButton( onPressed: () => Get.backLegacy(result: null), child: Text(negativeLabel), ), ], ), barrierDismissible: false, useSafeArea: true, ); return value; } }