showDoubleTextInput static method

Future<List<String>> showDoubleTextInput({
  1. String title = 'Title',
  2. String message = '',
  3. List<String>? initialTexts,
  4. List<String>? hintTexts,
  5. String cancelLabelText = 'Cancel',
  6. String okLabelText = 'OK',
})

显示双文本输入框弹窗

title 标题 message 内容 initialTexts 两个输入框的初始值(可选) hintTexts 两个输入框的hint(可选) cancelLabelText 取消按钮文本 okLabelText 确认按钮文本

返回结果

返回用户输入的字符串列表,两项(取消时 '',''

用法示例

final results = await PPAlert.showDoubleTextInput(
  title: "请输入账号和密码",
  hintTexts: ["账号", "密码"],
);

Implementation

static Future<List<String>> showDoubleTextInput({
  String title = 'Title',
  String message = '',
  List<String>? initialTexts,
  List<String>? hintTexts,
  String cancelLabelText = 'Cancel',
  String okLabelText = 'OK',
}) async {
  final texts = await showTextInputDialog(
    context: Get.context!,
    title: title,
    message: message.isNotEmpty ? message : null,
    textFields: [
      DialogTextField(
        initialText: initialTexts != null && initialTexts.isNotEmpty
            ? initialTexts[0]
            : '',
        hintText: hintTexts != null && hintTexts.isNotEmpty
            ? hintTexts[0]
            : '',
      ),
      DialogTextField(
        initialText: initialTexts != null && initialTexts.length > 1
            ? initialTexts[1]
            : '',
        hintText: hintTexts != null && hintTexts.length > 1
            ? hintTexts[1]
            : '',
      ),
    ],
  );
  // 返回结果:两项列表(如果取消,返回 ['',''])
  return texts ?? ['', ''];
}