Home > other >  Using methods and variables outside of class
Using methods and variables outside of class

Time:11-15

enter image description here

on my flutter app, I'm using some variables and functions like this, outside of class, without dependency injection so I can access them from everywhere.

the question is: Is this bad for performance or has any bad effect on my app?

CodePudding user response:

As I know this is not bad for performance because a lot of functions and variables we use in flutter like Colors class is outside the ui state class. And I all Get.* is outside the ui state class>

CodePudding user response:

It is not a good practice as far as Object Oriented Programming is concerned!

Encapulating methods, and fields is necessary to make our code work as it is intended, otherwise, anyone can change anything which could lead to potential problems down the lane.

As Andrea Bizzotto says "Making our code easy to use as it is intended and tougher to use otherwise"

  • Related