input static method

Future<String?> input(
  1. BuildContext context, {
  2. String title = '输入内容',
  3. String? hintText,
  4. String confirmLabel = '提交',
  5. String? initialValue,
})
  1. 输入对话框

Implementation

static Future<String?> input(
  BuildContext context, {
  String title = '输入内容',
  String? hintText,
  String confirmLabel = '提交',
  String? initialValue,
}) {
  final controller = TextEditingController(text: initialValue);
  return show<String>(
    context,
    type: NZDialogType.input,
    title: title,
    content: TextField(
      controller: controller,
      autofocus: true,
      style: TextStyle(
        fontSize: 15,
        color: Theme.of(context).brightness == Brightness.dark
            ? Colors.white
            : Colors.black,
      ),
      onSubmitted: (value) => Navigator.pop(context, value),
      decoration: InputDecoration(
        hintText: hintText,
        hintStyle: const TextStyle(fontSize: 14, color: Colors.grey),
        contentPadding: const EdgeInsets.symmetric(
          horizontal: 16,
          vertical: 12,
        ),
        filled: true,
        fillColor: Theme.of(context).brightness == Brightness.dark
            ? Colors.white.withValues(alpha: 0.05)
            : Colors.black.withValues(alpha: 0.03),
        border: OutlineInputBorder(
          borderRadius: BorderRadius.circular(12),
          borderSide: BorderSide.none,
        ),
        focusedBorder: OutlineInputBorder(
          borderRadius: BorderRadius.circular(12),
          borderSide: BorderSide(color: NZColor.nezhaPrimary, width: 1.5),
        ),
      ),
    ),
    actions: [
      NZDialogAction(label: '取消', onPressed: () => Navigator.pop(context)),
      NZDialogAction(
        label: confirmLabel,
        isPrimary: true,
        onPressed: () => Navigator.pop(context, controller.text),
      ),
    ],
  );
}