简体   繁体   中英

RenderBox was not laid out stack

Hello this is my error:

RenderBox was not laid out: RenderFlex#b7b0f relayoutBoundary=up1 NEEDS-PAINT 'package:flutter/src/rendering/box.dart': Failed assertion: line 1940 pos 12: 'hasSize'

This is my code:

@override
  Widget build(BuildContext context) {
    
    return Scaffold(
      body: FutureBuilder(
          future: createListOfMatches(),
          builder: (context, snapshot) {
            return Row(
              children: [match()],
            );
          }),
      floatingActionButton:
          FloatingActionButton(child: Text('next'), onPressed: () => next()),
    );
  }

match() {
    return Stack(
      children: [
        Positioned(
            top: top,
            left: left,
            child: Draggable(
              data: 10,
              onDragUpdate: (details) {
                top = top + details.delta.dy;
                left = left + details.delta.dx;
                print('$top, $left');
                setState(() {});
              },
              child: Material(
                  child: Container(
                      height: 50, width: 50, child: Image.asset('match.jpg'))),
              feedback: Material(
                  child: Container(
                      height: 50, width: 50, child: Image.asset('match.jpg'))),
            )),
      ],
    );
  }

thank you in advance

In the flutter documentation there are a few common failures:

there is also 'RenderBox was not laid out'"

While this error is pretty common, it's often a side effect of a primary error occurring earlier in the rendering pipeline.

What does the error look like?

The message shown by the error looks like this:

content_copy RenderBox was not laid out: RenderViewport#5a477 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

How might you run into this error?

Usually, the issue is related to violation of box constraints, and it needs to be solved by providing more information to Flutter about how you'd like to constrain the widgets in question. You can learn more about how constraints work in Flutter on the page Understanding constraints .

The RenderBox was not laid out error is often caused by one of two other errors:

'Vertical viewport was given unbounded height' 'An InputDecorator…cannot have an unbounded width'

I hope this could help you a little.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM