Home computickets Error: RenderBox was not laid out with the addition of TextFormField

Error: RenderBox was not laid out with the addition of TextFormField

Author

Date

Category

I recently started to learn programming language and flutter when creating applications in Android studio I get the error:

RenderBox was not laid out: _RenderDecoration # c6cd3 relayoutBoundary = up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

Explain to me, please, what am I doing wrong? Program code:

import 'package: flutter / material.dart';
class NewsBoxFavourit extends StatefulWidget {
 final int _num;
NewsBoxFavourit (this._num);
@override
 State & lt; StatefulWidget & gt; createState () = & gt; MyFormState ();
}
class MyFormState extends State {
 final _formKey = GlobalKey & lt; FormState & gt; ();
 @override
 Widget build (BuildContext context) {
  return Container (child: new Column (children: & lt; Widget & gt; [new Text ( 'qwqwqwqeee'),
    Expanded (child: new TextFormField ())
  ]));
 }
}
class NewsBox extends StatelessWidget {
 final String _title;
 final String _text;
 String _imageurl;
 int _num;
 NewsBox (this._title, this._text, {String imageurl, int num = 0}) {
  _imageurl = imageurl;
  _num = num;
 }
 @override
 Widget build (BuildContext context) {
  if (_imageurl = null & amp;! & amp; _imageurl = ''!) return new Container (
    color: Colors.black12,
    height: 100.0,
    child: new Row (children: [
     new Image.network (_imageurl, width: 100.0, height: 100.0, fit: BoxFit.cover,),
     new Expanded (child: new Container (padding: new EdgeInsets.all (5.0), child: new Column (children: [
      new Text (_title, style: new TextStyle (fontSize: 20.0), overflow: TextOverflow.ellipsis),
      new Expanded (child: new Text (_text, softWrap: true, textAlign: TextAlign.justify,))
     ]
     ))
     ), New NewsBoxFavourit (_num,)
    ])
  );
  return new Container (
    color: Colors.black12,
    height: 100.0,
    child: new Row (children: [
     new Expanded (child: new Container (padding: new EdgeInsets.all (5.0), child: new Column (children: [
      new Text (_title, style: new TextStyle (fontSize: 20.0), overflow: TextOverflow.ellipsis),
      new Expanded (child: new Text (_text, softWrap: true, textAlign: TextAlign.justify,))
     ]
     ))
     ), New NewsBoxFavourit (_num,)
    ])
  );
 }
}
void main () = & gt; runApp (
new MaterialApp (
debugShowCheckedModeBanner: false,
home: new Scaffold (
appBar: new AppBar (),
body: new NewsBox ( 'first day' '' 'Running' ''
imageurl: 'https://img.rl0.ru/0e5dfa5a89802f6ae40eea1312ee89c0/c615x400i/https/news.rambler.ru/img/2019/01/25160023.223341.8124.jpeg', num: 0)
)
)
);

The program tries to add or TextForm TextFormField, which
difference in them? How to properly add?


Answer 1, Authority 100%

Incorrect use Expanded , he fills the child ' th all available free space in the Flex widgets.

class MyFormState extends State {
 final _formKey = GlobalKey & lt; FormState & gt; ();
 @override
 Widget build (BuildContext context) {
  return Expanded (
   child: Column (
    children: & lt; Widget & gt; [
     Text ( 'qwqwqwqeee'),
     TextFormField (),
    ],
   ),
  );
 }
}

Difference TextField from TextFormfield In that TextFormField can integrate in Form , which allows you to work with several textFormfield fields simultaneously through one key .


p.s.:

  • keyword>new outdated, you can not write
  • in statelesswidget There should be no class fields (only Final or Const ), because It @immutable
  • '' 'text' '' use for Multi-Line Text

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions