Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.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
Flutter 颤振渲染DexedStack对象在布局过程中被赋予无限大的尺寸_Flutter_Dart_Layout_Flutter Layout_Flutter Widget - Fatal编程技术网

Flutter 颤振渲染DexedStack对象在布局过程中被赋予无限大的尺寸

Flutter 颤振渲染DexedStack对象在布局过程中被赋予无限大的尺寸,flutter,dart,layout,flutter-layout,flutter-widget,Flutter,Dart,Layout,Flutter Layout,Flutter Widget,我正在与这个DropDownItembox错误作斗争,一切似乎都正常,但在加载时会弹出黄色的边界。尝试了几件事,但都无法解决。我的小部件有这个代码 @override Widget build(BuildContext context) { var _children = <Widget>[ !_createNew ? _referrerPractice() : _referrerCreate(), ]; return new Scaffold(

我正在与这个
DropDownItem
box错误作斗争,一切似乎都正常,但在加载时会弹出黄色的边界。尝试了几件事,但都无法解决。我的
小部件有这个代码

@override
Widget build(BuildContext context) {
    var _children = <Widget>[
      !_createNew ? _referrerPractice() : _referrerCreate(),
    ];
    return new Scaffold(
        appBar: new AppBar(
          title: new Text(widget.title),
        ),
        body: new Column(
          mainAxisSize: MainAxisSize.max,
          children: _children,
        ));
  }

我能够复制你的问题,我不知道你为什么要这样构建布局。您正在将您的
下拉按钮
作为
InputDecorator
子属性输入,这很好。但是,它抛出此错误是因为
DropDownMenuItem
溢出了
InputDecorator
。换句话说,您不仅在
InputDecorator
中包含
DopDownButton
,而且您的
项也试图包含在相同的空间中。因此,对于如何将
项列表
放置在
InputDecorator
提供的空间内,Flatter感到困惑

我真的很困惑你想构建什么样的布局,为什么你需要一个
表单
和一个
输入装饰器

也许可以为您的设计选择提供一点背景,以便我们能够更好地帮助您

我用
文本字段
小部件创建了一个更简单的布局,它可能会有所帮助

类MyApp扩展StatefulWidget{
@凌驾
_MyAppState createState()=>new_MyAppState();
}
类MyAppState扩展了状态{
字符串(u)选举;;
字符串_text=“选择”;
列表_myJson=[
{“id”:“id1310012”,“name”:“Newcommer”},{“id”:“id0000temp”,“name”:“Temp”}];
Widget_children(){
TextEditingController\u controller=新的TextEditingController(text:\u text);
返回新扩展的(子项:新建ListView(
填充:常量边集。对称(水平:16.0),
儿童:[
新容器(
孩子:新的一排(
儿童:[
新扩展(
孩子:新文本字段(
控制器:_控制器,
),
),
新下拉按钮(
是的,
值:_mySelection,
项目:_myJson.map((映射){
返回新的DropdownMenuItem(
值:映射[“id”],
儿童:新文本(
映射[“名称”],
),
);
}).toList(),
onChanged:(字符串newValue){
设置状态(){
_mySelection=newValue;
_text=newValue;
});
})
],),),
新升起的按钮(
子项:新文本('Start'),onPressed:null),
]
));
}
@凌驾
小部件构建(构建上下文){
归还新脚手架(
appBar:新appBar(标题:新文本(“测试”)),
正文:新栏目(
mainAxisSize:mainAxisSize.max,
儿童:[
_儿童(),
],
),
);
}
}

我不太明白你的问题,你能说得更清楚些吗?你面临的错误是什么?你到底在哪里面对它?请把问题解释清楚?问题是什么?你能展示在另一个页面上工作的代码吗?所以我从Flatter examples为dropdownbutton举了一个例子,我使用输入装饰器,因为它允许图标、提示文本和标签。工作代码和非工作代码之间的唯一区别在于,在非工作代码中,我使用带有断言的小部件函数填充_子项,以从一种形式更改为另一种形式,而工作代码有一个静态列表,而不是动态创建的项列表。所以它抛出错误的原因很奇怪。任何其他的想法,使它与输入装饰将是伟大的,这样我就可以有图标等…你能告诉我的静态代码正在工作吗?另外,我仍然认为您根本不需要InputDecorator。当您打开刚才添加的静态视图上的下拉菜单时,您确定控制台上没有出现任何调试错误吗?我的意思是下拉菜单可以工作,我理解,但是你在你的控制台上看到了什么?我没有发现错误,我只是再次运行它,当非工作运行时,我得到了我在原始版本中显示的错误,但是工作的没有错误。这就是为什么它没有意义。我有这个简单的构建,我得到错误,我不明白它是如何与你一起工作的。
Widget _referrerPractice() {
assert(!_createNew);
return new Form(
  key: _formKey2,
  child: new Expanded(
    child: new ListView(
      padding: const EdgeInsets.symmetric(horizontal: 16.0),
      children: <Widget>[
        new InputDecorator(
          decoration: const InputDecoration(
            labelText: 'Referrer Practice',
            hintText: 'Choose Referrer Practice or choose new',
          ),
          isEmpty: _referPractice == null,
          child: new DropdownButton<String>(
            value: _referPractice,
            isDense: true,
            onChanged: (String newValue) {
              setState(() {
                _referPractice = newValue;
              });
            },
            items: practicelist.map((Map value) {
              return new DropdownMenuItem<String>(
                value: value['id'].toString(),
                child: new Text(value['name']),
              );
            }).toList(),
          ),
        ),
        new RaisedButton(
            child: new Text('Start'), onPressed: _startReferrer),
      ],
    ),
  ),
);
final List<String> _allTypeAppt = <String>['Elective OP', 'Hospital Transfer', 'Phone Consult'];

new Form(
      key: _formKey,
      autovalidate: _autovalidate,
      onWillPop: _warnUserAboutInvalidData,
      child: new Expanded(
          child: new ListView(
            padding: const EdgeInsets.symmetric(horizontal: 16.0),
            children: <Widget>[
              new TextFormField(
                decoration: const InputDecoration(
                  icon: const Icon(Icons.person),
                  hintText: 'First Name?',
                  labelText: 'First Name *',
                ),
                controller: _fnameController,

                onSaved: (String value) { referral.fname = value; },
                validator: _validateName,
              ),

              new TextFormField(
                decoration: const InputDecoration(
                  icon: const Icon(Icons.person),
                  hintText: 'Last Name?',
                  labelText: 'Last Name *',
                ),
                controller: _lnameController,
                onSaved: (String value) { referral.lname = value; },
                validator: _validateName,
              ),

              new _DateTimePicker(
                labelText: 'DOB',
                selectedDate: _fromDate,
                selectDate: (DateTime date) {
                  setState(() {
                    _fromDate = date;
                  });
                },
              ),

              new TextFormField(
                decoration: const InputDecoration(
                    icon: const Icon(Icons.phone),
                    hintText: 'How to contact?',
                    labelText: 'Phone Number *',
                ),
                controller: _phoneController,
                keyboardType: TextInputType.phone,
                onSaved: (String value) { referral.contact = value; },
                validator: _validatePhoneNumber,
                // TextInputFormatters are applied in sequence.
                /*inputFormatters: <TextInputFormatter> [
                  WhitelistingTextInputFormatter.digitsOnly,
                  // Fit the validating format.
                  _phoneNumberFormatter,
                ],*/
              ),

              new TextFormField(
                decoration: const InputDecoration(
                  icon: const Icon(Icons.phone),
                  hintText: 'Alt contact?',
                  labelText: 'Alt Phone Number *',
                ),
                controller: _altPhoneController,
                keyboardType: TextInputType.phone,
                onSaved: (String value) { referral.altcontact = value; },
                validator: _validatePhoneNumber,
                // TextInputFormatters are applied in sequence.
                /*inputFormatters: <TextInputFormatter> [
                  WhitelistingTextInputFormatter.digitsOnly,
                  // Fit the validating format.
                  _phoneNumberFormatter,
                ],*/
              ),

              new TextFormField(
                decoration: const InputDecoration(
                  icon: const Icon(Icons.email),
                  hintText: 'Patien Email?',
                  labelText: 'Patient Email *',
                ),
                controller: _emailController,
                onSaved: (String value) { referral.altcontact = value; },
                //validator: _validatePhoneNumber,
                // TextInputFormatters are applied in sequence.
                /*inputFormatters: <TextInputFormatter> [
                  WhitelistingTextInputFormatter.digitsOnly,
                  // Fit the validating format.
                  _phoneNumberFormatter,
                ],*/
              ),

              new TextFormField(
                decoration: const InputDecoration(
                  hintText: 'Tell us about patient',
                  helperText: 'It does not have to be detailed yet',
                  labelText: 'Referral Details',
                ),
                controller: _detailsController,
                maxLines: 5,
              ),

              new InputDecorator(
                decoration: const InputDecoration(
                  labelText: 'Type of Appointment',
                  hintText: 'Choose an Appointment Type',
                ),
                isEmpty: _typeAppt == null,
                child: new DropdownButton<String>(
                  value: _typeAppt,
                  isDense: true,
                  onChanged: (String newValue) {
                    setState(() {
                      _typeAppt = newValue;
                    });
                  },
                  items: _allTypeAppt.map((String value) {
                    return new DropdownMenuItem<String>(
                      value: value,
                      child: new Text(value),
                    );
                  }).toList(),
                ),
              ),

              new RaisedButton(
                child: new Text('Submit Referral'),
                onPressed: _submitData,
              ),

            ],

          )
      )
  ),
class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _mySelection;
  String _text = "Choose";
   List<Map> _myJson = [
    {"id": "ID 1310012", "name": "Newcommer"}, {"id": "ID 0000TEMP", "name": "Temp"}];

  Widget _children() {
    TextEditingController _controller = new TextEditingController(text: _text);
    return  new Expanded(child: new ListView(
            padding: const EdgeInsets.symmetric(horizontal: 16.0),
            children: <Widget>[
              new Container (
        child: new Row(
                  children: <Widget>[
                    new Expanded(
                      child: new TextField(
                        controller: _controller,
                      ),
                    ),
                    new DropdownButton(
                      isDense: true,
                      value: _mySelection,
                      items: _myJson.map((Map map) {
                        return new DropdownMenuItem<String>(
                          value: map["id"],
                          child: new Text(
                            map["name"],
                          ),
                        );
                      }).toList(),
                      onChanged: (String newValue) {
                        setState(() {
                          _mySelection = newValue;
                          _text = newValue;
                        });
                      })
              ],),),
              new RaisedButton(
                  child: new Text('Start'), onPressed: null),

            ]
        ));
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(title: new Text("Test")),
      body:  new Column(
        mainAxisSize: MainAxisSize.max,
        children: <Widget>[
           _children(),
        ],
      ),
    );
  }
}