How to reference widget class using String

Thank you, but why this is “a much better solution” ? is this beause of memory usage? (i’m new)