0

我创建了六位密码字段组件,它在较大尺寸的模拟器中按预期工作,但是当我使用小尺寸模拟器检查时,密码输入被键盘隐藏。

child: TextField(
            enableInteractiveSelection: false,
            focusNode: focusNode,
            controller: widget.controller,
            keyboardType: TextInputType.number,
            inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
            style: const TextStyle(
              height: 0.1,
              color: Colors.transparent,
            ),
            decoration: const InputDecoration(
              focusedErrorBorder: transparentBorder,
              errorBorder: transparentBorder,
              disabledBorder: transparentBorder,
              enabledBorder: transparentBorder,
              focusedBorder: transparentBorder,
              helperStyle: TextStyle(
                color: Colors.transparent,
              ),
              fillColor: Colors.transparent,
              border: InputBorder.none,
            ),
            cursorColor: Colors.transparent,
            showCursor: false,
            maxLength: widget.maxLength,
            onChanged: _onTextChanged,
          ),
4

2 回答 2

1

SingleChildScrollView用with 属性将整个列包裹在脚手架内reverse: true

像这样:

在此处输入图像描述

于 2021-05-17T11:10:09.597 回答
0

你能检查一下这个包吗:keyboard_visibility 你可以得到你的键盘状态,并基于那个隐藏/显示你的文本小部件。考虑以下代码:

class _LoginPageState extends State<LoginPage> {
  bool _isKeyboardVisible = false;
  StreamSubscription _subscription;

  @override
  void initState() {
    super.initState();

    _subscription =
        KeyboardVisibilityController().onChange.listen((bool visible) {
      setState(() => _isKeyboardVisible = visible);
    });
  }

  @override
  void dispose() {
    _subscription.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Visibility(
          visible: !_isKeyboardVisible,
          child: Text("Your header text"),
        ),
        Visibility(
          visible: !_isKeyboardVisible,
          child: Text("Your description text"),
        )
        TextField(
          ...
        ) // Your PIN widgets
      ]
    );
  }
}
于 2021-05-17T11:01:41.080 回答