showInputDialog static method

Future<String?> showInputDialog({
  1. required BuildContext context,
  2. required String title,
  3. String? subtitle,
  4. String? initialValue,
  5. String? hintText,
  6. String confirmText = 'Save',
  7. String cancelText = 'Cancel',
  8. int maxLines = 1,
  9. int? maxLength,
  10. TextInputType keyboardType = TextInputType.text,
  11. String? validator(
    1. String?
    )?,
})

Shows an input dialog with text field.

Implementation

static Future<String?> showInputDialog({
  required BuildContext context,
  required String title,
  String? subtitle,
  String? initialValue,
  String? hintText,
  String confirmText = 'Save',
  String cancelText = 'Cancel',
  int maxLines = 1,
  int? maxLength,
  TextInputType keyboardType = TextInputType.text,
  String? Function(String?)? validator,
}) async {
  final controller = TextEditingController(text: initialValue);

  return _showAdaptive<String>(
    context: context,
    builder: (context) => Padding(
      padding: EdgeInsets.only(
        bottom: MediaQuery.of(context).viewInsets.bottom,
      ),
      child: _DialogContainer(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            _DialogHeader(title: title, subtitle: subtitle),
            const SizedBox(height: 16),

            // Text field
            TextField(
              controller: controller,
              maxLines: maxLines,
              maxLength: maxLength,
              keyboardType: keyboardType,
              style: const TextStyle(color: Colors.white),
              decoration: InputDecoration(
                hintText: hintText,
                hintStyle: TextStyle(color: Colors.grey[600]),
                filled: true,
                fillColor: Colors.white.withValues(alpha: 0.05),
                border: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(12),
                  borderSide: BorderSide(
                    color: Colors.white.withValues(alpha: 0.1),
                  ),
                ),
                enabledBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(12),
                  borderSide: BorderSide(
                    color: Colors.white.withValues(alpha: 0.1),
                  ),
                ),
                focusedBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(12),
                  borderSide: const BorderSide(color: AppColor.bondiBlue75),
                ),
              ),
            ),
            const SizedBox(height: 24),

            // Buttons
            _DialogButtons(
              confirmText: confirmText,
              cancelText: cancelText,
              onConfirm: () {
                final value = controller.text.trim();
                if (validator != null) {
                  final error = validator(value);
                  if (error != null) {
                    // Show error - could use snackbar
                    return;
                  }
                }
                HapticFeedback.lightImpact();
                Sint.back(result: value);
              },
              onCancel: () => Sint.back(),
            ),
          ],
        ),
      ),
    ),
  );
}