I can think of these 3 ways to initialize a value using GetX
Initializing at the declaration:
class StatusPane extends StatelessWidget {
final HomeController homeController = Get.find();
StatusPane({Key? key}) : super(key: key);
in the initializer list:
class StatusPane extends StatelessWidget {
final HomeController homeController;
StatusPane({Key? key}) : homeController = Get.find(), super(key: key);
or in the constructor
class StatusPane extends StatelessWidget {
late final HomeController homeController;
StatusPane({Key? key}) : super(key: key) {
homeController = Get.find();
}
Is there any significant difference between the 3? Like, can one way lead to crashes or bugs? Or is one way better performance wise? Or are they actually identical? Would it be any different if GetX wasn't used, like final HomeController homeController = HomeController()
for example? Or is it pretty much down to personal preference?