首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何为ListView制作包装内容

如何为ListView制作包装内容
EN

Stack Overflow用户
提问于 2019-12-26 07:37:42
回答 1查看 1.2K关注 0票数 0

我需要使用表单输入字段进行对话,当我使用with内容适合于屏幕时,但是当我试图键入值时,它隐藏了下面的输入字段并提交了button.Show来解决这个问题,我只知道一个用listview代替列的解决方案,它允许我浏览,但是内容不适合屏幕。

如何使listview中的内容适合sceen?

这是我的完整代码

代码语言:javascript
运行
复制
import 'package:devaayanam/Confi.dart';
import 'package:flutter/material.dart';

class BookPujaDialogContent extends StatefulWidget {
  BookPujaDialogContent({Key key}) : super(key: key);

  @override
  _BookPujaDialogContentState createState() => _BookPujaDialogContentState();
}

class _BookPujaDialogContentState extends State<BookPujaDialogContent> {
  final _formKey =GlobalKey<FormState>();
  @override
  Widget build(BuildContext context) {
    return  Container(

      child: Form(
        key: _formKey,
        child: Column(
          mainAxisSize: MainAxisSize.min,

          children: <Widget>[
            TextFormField(
              decoration: InputDecoration(
                  labelText: Confi.TEMPLENAME
              ),
              validator: (value) {
                if (value.isEmpty) {
                  return 'Please enter '+Confi.TEMPLENAME;
                }
                return null;
              },
            ),
            TextFormField(
              decoration: InputDecoration(
                  labelText: Confi.DEITY
              ),
              validator: (value) {
                if (value.isEmpty) {
                  return 'Please enter '+Confi.DEITY;
                }
                return null;
              },
            ),
            TextFormField(
              decoration: InputDecoration(
                  labelText: Confi.BN
              ),
              validator: (value) {
                if (value.isEmpty) {
                  return 'Please enter '+Confi.BN;
                }
                return null;
              },
            ),
            TextFormField(
              decoration: InputDecoration(
                  labelText: Confi.STAR
              ),
              validator: (value) {
                if (value.isEmpty) {
                  return 'Please enter '+Confi.STAR;
                }
                return null;
              },
            ),
            Container(
              margin: EdgeInsets.only(top: 20),
              child: RaisedButton(

                onPressed: () {
                  // Validate returns true if the form is valid, or false
                  // otherwise.
                  if (_formKey.currentState.validate()) {
                    // If the form is valid, display a Snackbar.
                    Scaffold.of(context)
                        .showSnackBar(SnackBar(content: Text('Processing Data')));
                  }
                },
                textColor: Colors.white,
                padding: const EdgeInsets.all(0.0),
                shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
                child: Container(
                  decoration: const BoxDecoration(
                      gradient: LinearGradient(
                      colors: <Color>[
                        Color(0xFF0D47A1),
                        Color(0xFF1976D2),
                        Color(0xFF42A5F5),

      ],
      ),
                      borderRadius: BorderRadius.all(Radius.circular(10.0))
                  ),
                 width: MediaQuery.of(context).size.width,
                 height: 40,
                 // padding: const EdgeInsets.fromLTRB(45, 10, 45, 10),
                  child:  Center(
                    child: Text(
                        Confi.BOOKNOW,
                        style: TextStyle(fontSize: 16)
                    ),
                  ),
                ),
              ),
            )



          ],
        ),
      ),
    );
  }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-12-26 08:01:45

shirinkWrap: true设置为ListView

代码语言:javascript
运行
复制
Dialog(
  child: Form(
    key: _formKey,
    child: ListView(
      shrinkWrap: true, //TODO: Use this
      children: <Widget>[
        TextFormField(
          decoration: InputDecoration(labelText: Confi.TEMPLENAME),
          validator: (value) {
            if (value.isEmpty) {
              return 'Please enter ' + Confi.TEMPLENAME;
            }
            return null;
          },
        ),
        ....
        ....
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59485353

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档