简体   繁体   English

一个 RenderFlex 在底部溢出了 45 个像素?

[英]A RenderFlex overflowed by 45 pixels on the bottom?

I have a problem with Flutter (Dart) RenderFlex overflowed pixels.我对 Flutter (Dart) RenderFlex 溢出像素有疑问。 An exception of rendering library.渲染库的一个例外。

When keyboard opens it shows thar message below here:当键盘打开时,它会在下面显示消息:

A RenderFlex overflowed by 45 enter image description here pixels on the bottom.一个 RenderFlex 溢出了 45 在底部输入图像描述这里的像素。

if you by any chance need the full log to help me is here:如果您有任何机会需要完整的日志来帮助我,请点击此处:

  @override
  Widget build(BuildContext context) {
    return Card(
      elevation: 5,
      child: Container(
        margin: EdgeInsets.all(10),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.end,
          children: [
            TextField(
              decoration: InputDecoration(labelText: 'Title'),
              controller: _titleController,
              onSubmitted: (_) => _submitData,
              // onChanged: (val) {
              //   titleInput = val;
              // },
            ),
            TextField(
              decoration: InputDecoration(labelText: 'Amount'),
              controller: _amountController,
              keyboardType: TextInputType.number,
              onSubmitted: (_) => _submitData,
              // onChanged: (val) => amountInput = val,
            ),
            Container(
              height: 70,
              child: Row(
                children: [
                  Expanded(
                    child: Text(_selectedDate == null
                        ? "No Date Choosen!"
                        : 'Picked Date: ${DateFormat.yMd().format(_selectedDate)}'),
                  ),
                  TextButton(
                      onPressed: _presentDatePicker,
                      child: Text(
                        'Choose the Date!',
                        style: TextStyle(
                            color: Theme.of(context).primaryColor,
                            fontWeight: FontWeight.bold),
                      ))
                ],
              ),
            ),
            ElevatedButton(
              onPressed: _submitData,
              // () {
              // print(titleInput);
              // print(amountInput);
              // print(titleController.text);
              // print(amountController.text);
              //   addTx(
              //       titleController.text, double.parse(amountController.text));
              // },
              child: Text(
                'Add Transaction',
                style: TextStyle(color: Colors.white),
              ),
              style: ButtonStyle(
                  foregroundColor: MaterialStateProperty.all(Colors.purple)),
            )
          ],
        ),
      ),
    );
  }
}

You can add SingleChildScrollView to Card widget.您可以将SingleChildScrollView添加到 Card 小部件。 It will help to scroll your page and pixel error will be gone.这将有助于滚动您的页面,并且像素错误将消失。

you can wrap card widget by SinglechildScrollView which will make it scrollable so give adequate size for keyboard and also in Scaffold you can make it您可以通过 SinglechildScrollView 包装卡片小部件,这将使其可滚动,因此为键盘提供足够的尺寸,并且在 Scaffold 中您可以制作它

resizeToAvoidBottomInset: true,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM