Your Build Method is Not a Kitchen

Your Build Method is Not a Kitchen

Aug 09, 2025

Too many devs cook all their logic inside the build() method โ€” then wonder why their app lags.

Every time Flutter rebuilds, your build() runs again. If youโ€™re:

Doing API calls in there โŒ

Heavy calculations โŒ

Creating giant lists on the fly โŒ

โ€ฆyouโ€™re basically making your app redo the same expensive work over and over.

๐Ÿ”ง Example of a slow approach:

@override

Widget build(BuildContext context) {

final items = getItemsFromDatabase(); // โŒ BAD: runs every rebuild

return ListView(children: items.map((e) => Text(e)).toList());

}

โœ… Better: Do heavy work once in initState() or a state management class, then pass the data to your widget.

List<String> items = [];

@override

void initState() {

super.initState();

items = getItemsFromDatabase(); // โœ… Runs once

}

@override

Widget build(BuildContext context) {

return ListView(children: items.map((e) => Text(e)).toList());

}

๐Ÿง  Takeaway:

> โ€œbuild() is for building UI, not doing the cooking.โ€

If this tip saved your app from getting roasted, fuel the next spicy one here:

๐Ÿ‘‰ buymeacoffee.com/ejjat โ˜•

#flutterdev #performancetips #fluttertips #dailydev #buymeacoffee

Enjoy this post?

Buy Izzat Rizal a burger

More from Izzat Rizal