lukman azhari
lukman azhari

Reputation: 141

Flutter - A RenderFlex overflowed by 81 pixels on the bottom

good afternoon, I'm new in android programming. And I want to ask about the error in my code. the error is "The following assertion was thrown during layout: A RenderFlex overflowed by 81 pixels on the bottom." . I've tried to find a solution but still nothing works. and this is my code. thank you

class berita_secondpage extends StatelessWidget {
  final String title;

  berita_secondpage({
    this.title,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(title),
        ),
        body: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Expanded(
              child: Container(
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.only(
                          bottomLeft: Radius.circular(30),
                          bottomRight: Radius.circular(30)),
                      image: DecorationImage(
                        image: AssetImage("assets/images/aquaman.jpg"),
                        fit: BoxFit.cover,
                      ))),
            ),
            Container(
              height: 260,
              child: Column(
                children: <Widget>[
                  Padding(
                    padding: EdgeInsets.fromLTRB(20, 20, 20, 0),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        Text(
                          title,
                          style: TextStyle(
                            // color: Colors.lightBlueAccent,
                            fontSize: 25,
                            fontWeight: FontWeight.w600,
                          ),
                        ),
                        Text(
                          "diupload pada : 20 Agustus 2021",
                          style: TextStyle(
                            // color: Colors.lightBlueAccent,
                            fontSize: 10,
                            fontWeight: FontWeight.w600,
                          ),
                        ),
                        SizedBox(
                          width: 15,
                        ),
                        Text(
                          "testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing",
                          style: TextStyle(
                            // color: Colors.lightBlueAccent,
                            fontSize: 17,
                            fontWeight: FontWeight.w600,
                          ),
                        ),
                      ],
                    ),
                  )
                ],
              ),
            )
          ],
        ));
  }
}

Upvotes: 0

Views: 1086

Answers (4)

Samu Chakraborty
Samu Chakraborty

Reputation: 362

Your problem is the occur because of your 2nd container height. you give container height 260, but your text need more space for display. Remember, 'A RenderFlex overflowed ...... ' want to tell you that your data (image/text) need more space, but you give him little space.

class SecondPage extends StatelessWidget {
  final String title;
  SecondPage({required this.title});

     @override
     Widget build(BuildContext context) {
      return Scaffold(
         appBar: AppBar(
      title: Text(title),
    ),
    body: Container(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Expanded(
            child: Container(
              decoration: const BoxDecoration(
                color: Colors.red,
                borderRadius: BorderRadius.only(
                    bottomLeft: Radius.circular(30),
                    bottomRight: Radius.circular(30)),
                image: DecorationImage(
                  image: NetworkImage('https://picsum.photos/250?image=9'),
                  fit: BoxFit.cover,
                ),
              ),
            ),
          ),
          Container(
            height: 360,
            child: Column(
              children: <Widget>[
                Padding(
                  padding: EdgeInsets.fromLTRB(20, 20, 20, 0),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Text(
                        title,
                        style: const TextStyle(
                          // color: Colors.lightBlueAccent,
                          fontSize: 25,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                      const Text(
                        "diupload pada : 20 Agustus 2021",
                        style:  TextStyle(
                          color: Colors.lightBlueAccent,
                          fontSize: 10,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                      const   SizedBox(
                        width: 15,
                      ),
                      const Text(
                        "testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing",
                        style:  TextStyle(
                          // color: Colors.lightBlueAccent,
                          fontSize: 17,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                    ],
                  ),
                )
              ],
            ),
          )
        ],
      ),
    ));
 }
}

Upvotes: 1

HasanToufiqAhamed
HasanToufiqAhamed

Reputation: 971

Container(
              height: 260,
              child: SingleChildScrollView(
                child: Column(
                  children: <Widget>[
                    Padding(
                      padding: EdgeInsets.fromLTRB(20, 20, 20, 0),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Text(
                            title,
                            style: TextStyle(
                              // color: Colors.lightBlueAccent,
                              fontSize: 25,
                              fontWeight: FontWeight.w600,
                            ),
                          ),
                          Text(
                            "diupload pada : 20 Agustus 2021",
                            style: TextStyle(
                              // color: Colors.lightBlueAccent,
                              fontSize: 10,
                              fontWeight: FontWeight.w600,
                            ),
                          ),
                          SizedBox(
                            width: 15,
                          ),
                          Text(
                            "testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing",
                            style: TextStyle(
                              // color: Colors.lightBlueAccent,
                              fontSize: 17,
                              fontWeight: FontWeight.w600,
                            ),
                          ),
                        ],
                      ),
                    )
                  ],
                ),
              ),
            )

Upvotes: 0

HasanToufiqAhamed
HasanToufiqAhamed

Reputation: 971

You can wrap your Column in Wrap component

Container(
              height: 260,
              child: Wrap(
                children: [
                  Column(
                    children: <Widget>[
                      Padding(
                        padding: EdgeInsets.fromLTRB(20, 20, 20, 0),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                            Text(
                              title,
                              style: TextStyle(
                                // color: Colors.lightBlueAccent,
                                fontSize: 25,
                                fontWeight: FontWeight.w600,
                              ),
                            ),
                            Text(
                              "diupload pada : 20 Agustus 2021",
                              style: TextStyle(
                                // color: Colors.lightBlueAccent,
                                fontSize: 10,
                                fontWeight: FontWeight.w600,
                              ),
                            ),
                            SizedBox(
                              width: 15,
                            ),
                            Text(
                              "testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing",
                              style: TextStyle(
                                // color: Colors.lightBlueAccent,
                                fontSize: 17,
                                fontWeight: FontWeight.w600,
                              ),
                            ),
                          ],
                        ),
                      )
                    ],
                  ),
                ],
              ),
            )

Upvotes: 0

esentis
esentis

Reputation: 4726

You can try adding your second Container to a Flexible widget. The error simply says that the widget is larger than the viewport.

Upvotes: 0

Related Questions