close
setState() or markNeedsBuild called during build A vertical renderflex overflowed, setState() or markNeedsBuild called during build, markNeedsBuild called during build A vertical renderflex overflowed, setState() or markNeedsBuild called, setState() or markNeedsBuild called during build A vertical renderflex

[Solved] setState() or markNeedsBuild called during build A vertical renderflex overflowed

Hello Guys, How are you all? Hope You all Are Fine. Today I am just trying to make alertDialog but I am facing following error setState() or markNeedsBuild called during build A vertical renderflex overflowed in flutter. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How setState() or markNeedsBuild called during build A vertical renderflex overflowed Error Occurs ?

I am just trying to make alertDialog but I am facing following error.

setState() or markNeedsBuild called during build A vertical renderflex overflowed by 204 pixels

How To Solve setState() or markNeedsBuild called during build A vertical renderflex overflowed Error ?

  1. How To Solve setState() or markNeedsBuild called during build A vertical renderflex overflowed Error ?

    To Solve setState() or markNeedsBuild called during build A vertical renderflex overflowed Error You just need to use a call back function. Because Should be setState method call before the build method had completed the process of building the widgets and thats why you are facing this error. Second solution is Just use SchedulerBinding Or Just Use Future.delayed.

  2. setState() or markNeedsBuild called during build A vertical renderflex overflowed

    To Solve setState() or markNeedsBuild called during build A vertical renderflex overflowed Error You just need to use a call back function. Because Should be setState method call before the build method had completed the process of building the widgets and thats why you are facing this error. Second solution is Just use SchedulerBinding Or Just Use Future.delayed.

Solution 1: use a call back function

You just need to use a call back function. Because Should be setState method call before the build method had completed the process of building the widgets and thats why you are facing this error.

WidgetsBinding.instance.addPostFrameCallback((_){

  // Your Code Here

});

Solution 2: use SchedulerBinding

Just use SchedulerBinding Just as below.

SchedulerBinding.instance.addPostFrameCallback((_) {

  // Your Code
});

Solution 3: Change this

If you are making alertdialoge then its should be on button click so that you need to use as given below.

onPressed: myAlertDialogue(),

Instead of above Use this.

onPressed: () => myAlertDialogue(),

Solution 4: Use Future.delayed

Just Use Future.delayed.

Future.delayed(Duration.zero, () async {
  // Your Function
});

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read


Posted

in

by

Tags:

Comments

4 responses to “[Solved] setState() or markNeedsBuild called during build A vertical renderflex overflowed”

  1. Cloud Avatar
    Cloud

    Thank you for the method

  2. Abdulrahman Avatar
    Abdulrahman

    Thank you, solution 2 helped me.

  3. Umar Avatar
    Umar

    Solution Number 3 helped me, thanks alot

  4. Hamza Avatar
    Hamza

    Thanks a lot.
    Before:
    delete: () {
    setState(() {
    quotes.remove(quote);
    });
    After:
    delete: () {
    setState(() {
    Future.delayed(Duration.zero);
    quotes.remove(quote);
    });
    it solved the problem

Leave a Reply

Your email address will not be published. Required fields are marked *