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 ?
- 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 thebuild
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. - 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 thebuild
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
- Could not open settings generic class cache for settings file
- Exception in thread “main” java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema Flutter
- java.lang.IllegalArgumentException: Component class com.google.android.gms.wallet.ocr.CardRecognitionShimProxyActivity
- xcodebuild: WARNING: Using the first of multiple matching destinations
- Exception in thread “main” java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema in flutter
Leave a Reply