I have a code like these
Future.delayed(Duration(seconds: 5),(){
print("5 seconds");
});
in
import 'package:flutter/material.dart';
class Loading extends StatefulWidget {
const Loading({Key? key}) : super(key: key);
@override
State<Loading> createState() => _LoadingState();
}
class _LoadingState extends State<Loading> {
int counter=0;
@override
Widget build(BuildContext context) {
Future.delayed(Duration(seconds: 5),(){
print("5 seconds");
});
return Scaffold(
appBar: AppBar(
title: Text("Loading"),
centerTitle: true,
),
body:TextButton(
onPressed: () {
setState((){
counter++;
});
},
child: Text("Counter is $counter"),
),
);
}
void getstart(){
Future.delayed(Duration(seconds: 3),(){
print("3 seconds");
}
);
}
@override
void initState() {
getstart();
print("this is innit State");
}
@override
void dispose() {
print("this is dispose");
}
}
when I ran Asynchronous Code it print 2 "5 second" in build widget, I dont know why it happens