Using flutter 2.x
and Get package
version ^4.1.2
.
i have a widget like so:
class InitializationScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: FutureBuilder(
future:
// this is just for testing purposes
Future.delayed(const Duration(seconds: 4)).then((value) => "done"),
builder: (context, snapshot) {
if (shouldProceed(snapshot)) {
Get.toNamed("/login");
}
if (snapshot.hasError) {
// handle error case ...
}
return const Center(child: CircularProgressIndicator());
},
),
);
}
bool shouldProceed(AsyncSnapshot snapshot) =>
snapshot.hasData && snapshot.connectionState == ConnectionState.done;
}
Get.toNamed("/login");
used inside FutureBuilder
leads to this error:
The following assertion was thrown building FutureBuilder(dirty, state: _FutureBuilderState#b510d): setState() or markNeedsBuild() called during build.
- I tried to check the
connectionStatus
(based on a SO answer) but it didn't work.
any help?