【问题标题】:Flutter: AlertDialog TextField and Overflowed Problem *Used SingleChildScrollViewFlutter:AlertDialog TextField 和溢出问题 *Used SingleChildScrollView
【发布时间】:2021-08-15 09:08:23
【问题描述】:
return AlertDialog(
    title: Center(
      child: Text(
        'OVERLFOWED',
        style: defaultStyle,
        overflow: TextOverflow.ellipsis,
      ),
    ),
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(40),
    ),
    elevation: 2.0,
    backgroundColor: Colors.grey[900],
    content:  Container(
        height: context.height * 0.45,
        width: context.width * 0.9,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
           Container(
                    height: context.height * 0.390,
                    width: context.width * 0.9,
                    child: SingleChildScrollView(
                      scrollDirection: Axis.vertical,
                      child: Column(
                        children: [
                          Container(
                            color: Colors.blue,
                            height: context.height * 0.030,
                            width: context.width * 0.9,
                            child: TextField(),
                          ),
                          Container(
                            color: Colors.red,
                            height: context.height * 0.360,
                            width: context.width * 0.9,
                            child: Wrap(
                              spacing: 10.0,
                              runSpacing: 10.0,
                              children: <Widget>[],
                            ),
                          )
                        ],
                      ),
                    ),
                  ),
            SizedBox(height: context.height * 0.02),
            Container(
              height: context.height * 0.035,
              width: context.width * 0.9,
              child:  ElevatedButton(
                      onPressed: () async {
                        Navigator.pop(context);
                      },
                      child: Text('Done', style: _textButtonStyle)),
            ),
          ],
        ),
      );
    ));

当我点击Textfield 时,应用程序会导致溢出问题。大多数解决方案就像将resizeToAvoidBottomInset 添加到您的脚手架。但是,我使用的是 AlertDialog() 并出现此错误。我还添加了SingleChildScrollView。如果它正在解决错误但没有运气。

我认为其他小部件正在影响布局。所以,我删除了除SingleChildScrollView 和TextField 之外的所有内容,但仍然遇到同样的问题。

我该如何在AlertDialog() 上处理这个问题?

【问题讨论】:

    标签: flutter flutter-layout


    【解决方案1】:

    将滚动条设置为true

    AlertDialog(
      scrollable: true,
      ...
      ...
    )
    

    【讨论】:

      猜你喜欢
      • 2022-11-14
      • 2020-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 2019-12-17
      • 2021-09-02
      • 1970-01-01
      相关资源
      最近更新 更多