K.k
K.k

Reputation: 489

How to pass argument using getx?

Get.rootDelegate.toNamed('/note', arguments: 'test_data');

Get.arguments <= It makes null.

How can I solve this problem?

Upvotes: 3

Views: 5210

Answers (3)

Benjamin
Benjamin

Reputation: 8248

When using rootDelegate in GetX, you. no longer get the arguments via Get.arguments but rather using Get.rootDelegate.arguments() (note arguments is a function).

In your case the correct way is as follows:

Get.rootDelegate.toNamed('/note', arguments: 'test_data');

Get.rootDelegate.arguments() // Result: 'test_data'

Upvotes: 0

PradeepKumar
PradeepKumar

Reputation: 340

Send arguments

  Map<String, dynamic> parameter = {
      'name': "pradeep",
      'object': SomeObject,
     
    };

Get.rootDelegate.toNamed(Routes.nextpage, arguments: parameter );

Recieve arguments

var someObject= Get.rootDelegate.arguments()['object'];

Upvotes: 2

Xuuan Thuc
Xuuan Thuc

Reputation: 2521

I think you migh be missing something. While you're setting this parameters using the rootDelegate

onPressed: () => Get.rootDelegate.toNamed(Routes.RECEIVER, arguments: true, parameters: {'bool': 'true'}),

You try to retrieve them from the Get context:

Get.arguments

You should be using:

Get.rootDelegate.parameters

Get.rootDelegate.parameters will work

Upvotes: 3

Related Questions