I have the below FutureBuilder entry.
FutureBuilder(
future: _checkConn,
builder: (BuildContext context, AsyncSnapshot snapshot) {
switch (snapshot.connectionState){
case ConnectionState.none:
Navigator.pushReplacementNamed(context, NoConnView);
break;
case ConnectionState.active:
case ConnectionState.waiting:
case ConnectionState.done:
if(snapshot.data=='OK'){
initialfbget();
break;
} else {
Navigator.pushReplacementNamed(context, NoConnView);
break;
}
}
return SizedBox.expand(
child: FittedBox(
fit: BoxFit.fill,
child: SizedBox(
width: _vcontroller.value.size?.width ?? (MediaQuery.of(context).size.width),
height: _vcontroller.value.size?.height ?? (MediaQuery.of(context).size.height),
child: VideoPlayer(_vcontroller),
),
),
);
}
),
The below is the complete initstate section:
void initState() {
super.initState ();
_vcontroller = VideoPlayerController.asset("assets/testimages/sukiitestanimation.mp4")
..initialize().then((_) {
// Once the video has been loaded we play the video and set looping to true.
_vcontroller.play();
_vcontroller.setLooping(false);
// Ensure the first frame is shown after the video is initialized.
});
_checkConn = checkConn();
Firebase.initializeApp();
}
Below is the checkconn segment:
Future<String> checkConn() async {
var connresponse = await http.get(connurl).timeout(const Duration(seconds: 10));
log('connresponse is: ${connresponse.statusCode}');
if(connresponse.statusCode!=200) {
return "BAD";
} else {
return "OK";
}
}
Kept on receiving the below error.
setState() or markNeedsBuild() called during build.
Would appreciate any assistance on this.
Thanks in advance.