is it a good practice to send data with arguments in flutter using GetX (or any other way)? i mean is it good for performance and ram capcity ? ... like this example:

Get.toNamed(AppPages.servicesDetails, arguments: [service]);

when (service) contain a data for only one product came from API : like (id, name, info, image ...etc).

and in the servicesDetails page:

 final s = Get.arguments[0];
  @override
  Widget build(BuildContext context) {
    return  Scaffold(
      body:  Center(child: Text(s.name),),


Solution 1: Arbiter Chil

You can also used parameters.

 var  data = {
      "email" : "[email protected]",
      "message" : "hi!"
   };
  Get.toNamed(YourRouteName.name, parameters: data);

Also from getting it from another pages is like this.

  print(Get.parameters['email']);

Also on Getx you can pass it like a url link on data as the document written.

https://github.com/jonataslaw/getx/blob/master/documentation/en_US/route_management.md

If you want to pass whole item data, You can also pass a model from list if have onTap function though you need to decode it again

e.g

MyCardItemFromList(
 name: list[index].name,
 ontapFunction: () => Get.toNamed(
   YourRouuteName.name,
   parameters: {
       /// Lets assume this is the item selected also it's own item data
       "itembyIndex": jsonEncode(list[index]),
    }
 ),
),

from controller

class MyXampleController extends GetxController{

//declare the model
final Rx<Model> model = Model().obs;

 @override
  void onInit() {
    convertToDecode();
    super.onInit();
  } 
  convertToDecode(){
    final decode = jsonDecode(Get.parameters['itembyIndex']) 
    final passToModel = Model.fromJson(decode);
    model(passToModel);
    // or if you are using getBuilder
    // try do it like this
    // model.value = passToModel;
     // update();
    // don't forget to call update() since it's needed from getbuilder;

  }
}

Now, For calling the data from ui will be like this

final controller = Get.put(MyXampleController());
///// this will be the data we got from the item
controller.model.value.name


Solution 2: aman

You can simply use arguments

Get.toNamed(
      '/my-route',
      arguments: "Hello",
    );

on the second screen, you can do

final title = Get.arguments as String;