Reputation: 836
I am just trying a random thing to clear my doubt but when I ran the code below the printing() function executes 2 times, can someone explain to me why the printing function executes 2 times.
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
printing() {
print("printing");
}
@override
Widget build(BuildContext context) {
printing(); //calling printing() function
return Container();
}
}
op(in console):
printing
printing
Upvotes: 0
Views: 40
Reputation: 2215
You should run your app in debug mode to understand what happens because there is no reason that your printing
method is called twice.
I have tested your example and I have only one printing
output in my console
Upvotes: 1