1
resposta

[Dúvida] Should i use less complex widgets for best flutter performance?

I prefer to use a Column with SizedBox to build space layout ! But my boss keep saying that i should use a Container with padding because container is less complex widget and should perform better. He always says that i should avoid stack widget because is a complex widget. But i think i remember from a flutter video that doesn't matter which widgets you choose, because flutter optimizes it when it builds the three trees ! Is that true ? should i spend time optimizing my widgets with less complex widgets as possible ?

Column(
    mainAxisAlignment: MainAxisAlignment.start,
    children: [
    SizedBox(height: 24),
    Text(
    text,
   ),
 ],
);

Container(
     padding: EdgeInsets.only(top: 24),
     child: Text(
     text,
    ),
  );

In Flutter padding desing discussion they said that doesn't matter if you use container with padding or specific padding widget. But i'm still in doubt if i should use less complex widget in general.

1 resposta

Hello Natalia, how are you ?

Maybe he said about putting padding on each component you have, so in this specific case it's better to put it in the container and reuse it in your hierarchy, but each type of layout has its complexity, so using only one padding for the entire screen might not work

I don't see any kind of problem using padding in your stack.