Aquarius_Girl
Aquarius_Girl

Reputation: 22906

Create instance of a class in Flutter with Get.put

This page says: https://pub.dev/packages/get

Get.put( Instance() ) // Access data from one screen in another screen easily.

So, what would be the difference between

  1. Instance obj;
  2. Instance obj = Instance()
  3. Instance obj = Get.put( Instance() )

?

Upvotes: 1

Views: 297

Answers (1)

Mohsen Parvar
Mohsen Parvar

Reputation: 176

difference is Getx has controll over the instance

for example you can remove the instance from memory with getx and onClose will be called

or you can find the instance in memory with Get.find(), and other benefits of letting Getx manage the instance

1 doesn't mean anything

2 has the problem that i said

3 Instance obj = is not required

Upvotes: 1

Related Questions