import 'package:flutter/material.dart'; class InputBox extends StatelessWidget { String hintText = ""; Function(String) changed; Function() onSubmit; Function() onCancel; bool isDefault = false; bool showsCaseSensitiveWarning = false; bool isNumeric = false; String promptText = ""; bool hasInputField = true; TextEditingController value = TextEditingController(); InputBox(String defaultText, {super.key, this.hintText = "", required this.promptText, required this.changed, required this.onSubmit, required this.onCancel, required this.isDefault, this.showsCaseSensitiveWarning = false, this.isNumeric = false, this.hasInputField = true}) { if (isDefault) { value.text = ""; } else { value.text = defaultText; } } @override Widget build(BuildContext context) { return AlertDialog( backgroundColor: Color.fromARGB(179, 0, 145, 125), icon: Icon(showsCaseSensitiveWarning ? Icons.warning : Icons.info), elevation: 8, actions: [ ElevatedButton( onPressed: () { onSubmit(); Navigator.of(context).pop(); }, style: ButtonStyle( backgroundColor: WidgetStateColor.resolveWith( (states) => const Color.fromARGB(255, 0, 83, 3))), child: hasInputField ? Text("Submit") : Text("OK"), ), ElevatedButton( onPressed: () { onCancel(); Navigator.of(context).pop(); }, style: ButtonStyle( backgroundColor: WidgetStateColor.resolveWith( (states) => const Color.fromARGB(255, 109, 7, 0))), child: Text("Cancel")) ], content: SizedBox( height: 128, //decoration: BoxDecoration( //border: Border.all(style: BorderStyle.solid), //borderRadius: BorderRadius.all(Radius.circular(12))), child: Column( children: [ if (showsCaseSensitiveWarning) Text("WARNING: Case Sensitive"), Text(promptText), if (hasInputField) TextField( decoration: InputDecoration( border: OutlineInputBorder(), hintText: hintText), onChanged: changed, controller: value, keyboardType: isNumeric ? TextInputType.number : TextInputType.text, ), Row( children: [], ) ], ))); } }