setState() or markNeedsBuild() called during build error for FutureBuilder

Issue

for my BottomNavigator Bar I am using Getx navigation like this:

else if (selectedPage == 3) {
   
      Get.to(VideoViewDetail(id: '1465'));

but I am getting following error:

The following assertion was thrown building FutureBuilder(dirty, state: _FutureBuilderState#03585):
setState() or markNeedsBuild() called during build.

any help?

Solution

As described in this answer, use

Future.microtask(() => Get.to(VideoViewDetail(id: '1465')));

Answered By – enzo

Answer Checked By – Clifford M. (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.