Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
对话框中的Listview,适合文本_Listview_Flutter_Dart_Dialog - Fatal编程技术网

对话框中的Listview,适合文本

对话框中的Listview,适合文本,listview,flutter,dart,dialog,Listview,Flutter,Dart,Dialog,我有一个自定义对话框,包含两个字符串,一个标题,一个内容,我希望将内容视为长字符串的列表视图。这就是我到目前为止所做的: @override dialogContent(BuildContext context) { return Stack( children: <Widget>[ Container( padding: EdgeInsets.only( top: Consts.avatarRadi

我有一个自定义对话框,包含两个字符串,一个标题,一个内容,我希望将内容视为长字符串的列表视图。这就是我到目前为止所做的:

@override
  dialogContent(BuildContext context) {
    return Stack(
      children: <Widget>[
        Container(
          padding: EdgeInsets.only(
            top: Consts.avatarRadius + Consts.padding,
            bottom: Consts.padding,
            left: Consts.padding,
            right: Consts.padding,
          ),
          margin: EdgeInsets.only(top: Consts.avatarRadius),
          decoration: new BoxDecoration(
            color: Colors.white,
            shape: BoxShape.rectangle,
            borderRadius: BorderRadius.circular(Consts.padding),
            boxShadow: [
              BoxShadow(
                color: Colors.black26,
                blurRadius: 10.0,
                offset: const Offset(0.0, 10.0),
              ),
            ],
          ),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Text(
                title,
                style: TextStyle(
                  fontSize: 28.0,
                  fontWeight: FontWeight.bold,
                  fontFamily: "Rubik1",
                ),
              ),
              SizedBox(height: 16.0),
              Container(
                child: ListView(
                  shrinkWrap: true,
                  children: <Widget>[
                    Text(
                      description,
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        fontSize: 24.0,
                        fontFamily: "Rubik1",
                      ),
                    ),
                    SizedBox(height: 24.0),
                    Align(
                      alignment: Alignment.center,
                      child: RaisedButton(
                        shape: new RoundedRectangleBorder(
                            borderRadius: new BorderRadius.circular(16.0),
                            side: BorderSide(color: Colors.blue)),
                        onPressed: () {
                          Navigator.of(context).pop(); // To close the dialog
                        },
                        textColor: Colors.white,
                        color: Colors.blue,
                        child: Text(
                          buttonText,
                          style: TextStyle(
                              fontSize: 24.0, fontWeight: FontWeight.bold),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
        Positioned(
            left: MediaQuery.of(context).size.width / 4,
            child: CircleAvatar(
              backgroundImage: AssetImage(picture),
              radius: Consts.avatarRadius,
              backgroundColor: Colors.transparent,
            )),
      ],
    );
  }
问题是字符串太长=>

问题是由于字符串长度导致底部溢出

有没有关于如何让它工作的建议?谢谢

您可以使用它来防止小部件渲染问题

   AutoSizeText(
                    "description",
                    textAlign: TextAlign.center,
                   minFontSize: 18,
                   maxLines: 16,
                   overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                      fontSize: 24.0,
                      fontFamily: "Rubik1",
                    ),
                ),

那太好了,但是我想允许长文本,而不让它看起来越来越小。有没有办法在对话框中创建列表视图?。@Prasath