微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何修复这个特殊的“ParentDataWidget 的错误使用”飞镖

如何解决如何修复这个特殊的“ParentDataWidget 的错误使用”飞镖

所以我一直在寻找有关此错误的在线答案,并且他们总是建议我将 ExpandedColumnFlex 包装起来,或 。但就我而言,它只是不起作用,在这里,看看我的代码

Widget _getActionButtons() {
return Padding(
  padding: EdgeInsets.only(left: 25.0,right: 25.0,top: 45.0),child: new Row(
    mainAxisSize: MainAxisSize.max,mainAxisAlignment: MainAxisAlignment.start,children: <Widget>[
      Flex(
        mainAxisAlignment: MainAxisAlignment.start,direction: Axis.vertical,children: [
          Expanded(
            child: Padding(
              padding: EdgeInsets.only(left: 10.0),child: Container(
                  child: new RaisedButton(
                child: new Text("Cancel"),textColor: Colors.white,color: Colors.pink[800],onpressed: () {
                  setState(() {
                    _status = true;
                    FocusScope.of(context).requestFocus(new FocusNode());
                  });
                },shape: new RoundedRectangleBorder(
                    borderRadius: new BorderRadius.circular(20.0)),)),),flex: 2,],

Here's the error message

如果你们能帮我找到罪魁祸首,我会很高兴..谢谢!

解决方法

您有一个扩展的小部件作为容器小部件的子部件,这在 Flutter 中是不允许的。

展开的小部件应该只是小部件的直接子代,例如 Column、Row、...

,

你的例子对我来说很好用..只需确保在具有指定高度的小部件中调用 _getActionButtons() 否则删除 Flex 小部件。

例如像这样

Container(height: 200.0,child: _getActionButtons(),),

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。