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

Get.arguments <= It makes null.

How can I solve this problem?

Ken White
  • 123,280
  • 14
  • 225
  • 444
K.k
  • 367
  • 1
  • 8
  • 17

3 Answers3

3

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

Xuuan Thuc
  • 2,340
  • 1
  • 5
  • 22
  • This answer doesn't answer the question but rather gives a workaround. This ay work for very simple arguments (like bool or String) being passed but DOES NOT WORK if you wish to pass complex arguments such as Objects or Custom Classes. – Benjamin Apr 11 '23 at 17:42
1

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'];
PradeepKumar
  • 138
  • 8
0

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'
Benjamin
  • 8,128
  • 3
  • 34
  • 45